Support #1244
closedWhich is the best way to define macro "__cplusplus" when I use crystax?
0%
Description
!http://7xoj7k.com1.z0.glb.clouddn.com/16-1-31/8273847.jpg!
When I use crystax, I still can't use C11.
Finally I find the reason is the macro "__cplusplus" still not defined.
I defined the following options in file "Application.mk"
APP_PLATFORM := android-16
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION=5
APP_CPPFLAGS += -fno-rtti -fexceptions
APP_CPPFLAGS +=-fpermissive
APP_CPPFLAGS += -std=c++11
What else should I do to make C11 correctly work?
Files
Updated by Dmitry M. about 8 years ago
- Status changed from Open to Waiting for feedback
- Assignee set to Dmitry M.
This macro is automatically defined if you use C++ compiler (i.e. @g++@ or @gcc -x c++@) . Obviously, you're doing something wrong, if it is undefined. The only reason I can guess right now is that you're compiling it in non-C++ mode. The simplest way to ensure that C++ compiler is used is making all sources ending by @.cpp@ extension. If this is not the case, or doesn't help, please provide minimal example, reproducing the problem.
Updated by Mario L. about 8 years ago
Dmitry Moskalchuk wrote:
This macro is automatically defined if you use C++ compiler (i.e. @g++@ or @gcc -x c++@) . Obviously, you're doing something wrong, if it is undefined. The only reason I can guess right now is that you're compiling it in non-C++ mode. The simplest way to ensure that C++ compiler is used is making all sources ending by @.cpp@ extension. If this is not the case, or doesn't help, please provide minimal example, reproducing the problem.
I upload the minimal example, just make a new project "Android Application Project", then "Add native support".
Add the file "Appllication.mk".
After I click "build project" , all the header file (.h) can be correctly found.
Then I jump into the header file , I find that the macro "__cplusplus" still can not be found. Just like the picture I show above.
Updated by Mario L. about 8 years ago
Unfortunately, I can not find the file I just uploaded.
I try to upload the minimal example again.
Updated by Mario L. about 8 years ago
I still can not find the minimal example, maybe something is wrong with Redmine?
I have to upload the file to a network disk:
Updated by Dmitry M. about 8 years ago
Mario Li wrote:
I still can not find the minimal example, maybe something is wrong with Redmine?
Here is limitation for file size. It must be less than 4 MB. Probably you're exceeding this limit by including built binaries. Please cleanup everything and provide minimal example.
I have to upload the file to a network disk:
I can't download that file, my browser report about harmful script on that page.
Updated by Mario L. about 8 years ago
- File test_macro_cplusplus.zip test_macro_cplusplus.zip added
I delete libs and obj folders to make the .zip file smaller, this time I think I will success!!!
Updated by Dmitry M. about 8 years ago
- Has duplicate Support #1251: Which is the best way to define macro "__cplusplus" when I use crystax? added
Updated by Dmitry M. about 8 years ago
- Status changed from Waiting for feedback to In Progress
Updated by Dmitry M. about 8 years ago
- Status changed from In Progress to Rejected
Mario Li wrote:
I delete libs and obj folders to make the .zip file smaller, this time I think I will success!!!
Your example works just fine. I've added this at begin of @jni/test_macro_cplusplus.cpp@:
#if !defined(cplusplus)
#error "cplusplus is not defined!"
#endif
And it compiles without any errors:
$ /opt/android/crystax-ndk-10.3.1/ndk-build
[armeabi-v7a] Compile++ thumb: test_macro_cplusplus <= test_macro_cplusplus.cpp
[armeabi-v7a] SharedLibrary : libtest_macro_cplusplus.so
[armeabi-v7a] Install : libcrystax.so => libs/armeabi-v7a/libcrystax.so
[armeabi-v7a] Install : libtest_macro_cplusplus.so => libs/armeabi-v7a/libtest_macro_cplusplus.so
I presume you've been mistaken by your IDE, which for some reason doesn't handle C++ code properly (looking on screenshot, I suppose it's Eclipse). Maybe it's wrong Eclipse settings, maybe it's Eclipse bug (it have problems with parsing more-or-less non-trivial C++ code for years). You shouldn't rely on IDE logic, doing such conclusions. Compiler is the only one whose behaviour is important.
This is definitely not the CrystaX NDK issue, so closing this ticket as "Invalid".