C++ 14 error with Qt 5.6.1
-
What's your compiler / compiler version?
-
I am using android ndk r12 for building this code. I think it has gcc 4.8
-
I am using android ndk r12 for building this code. I think it has gcc 4.8
gcc 4.8
https://gcc.gnu.org/projects/cxx-status.html
Some (or rather most) c++14 features will not be available for that compiler, or may be partially implemented.
-
I am using android ndk r12 for building this code. I think it has gcc 4.8
@Rubin-Stove Yepp, @kshegunov is right. I just tested the following code...
#include <shared_mutex> #include <mutex> #include <iostream> class R { mutable std::shared_timed_mutex mut; public: R& operator=(const R& other) { std::unique_lock<std::shared_timed_mutex> lhs(mut, std::defer_lock); std::shared_lock<std::shared_timed_mutex> rhs(other.mut, std::defer_lock); std::lock(lhs, rhs); return *this; } }; int main() { R r; std::cout << "Hello" << std::endl; return 0; }
... on Linux and the lowest possible compiler version it works with is GCC 4.9 with C++14 features explicitly enabled.
-
@Rubin-Stove Yepp, @kshegunov is right. I just tested the following code...
#include <shared_mutex> #include <mutex> #include <iostream> class R { mutable std::shared_timed_mutex mut; public: R& operator=(const R& other) { std::unique_lock<std::shared_timed_mutex> lhs(mut, std::defer_lock); std::shared_lock<std::shared_timed_mutex> rhs(other.mut, std::defer_lock); std::lock(lhs, rhs); return *this; } }; int main() { R r; std::cout << "Hello" << std::endl; return 0; }
... on Linux and the lowest possible compiler version it works with is GCC 4.9 with C++14 features explicitly enabled.
-
Looks like experimental support of C++14 in gcc is causing me this error. Somehow, I need to upgrade gcc in ndk r12 to 4.9 or above
-
Really strange. If you check toolchains folder of ndk r12, it looks to be on gcc 4.9
https://developer.android.com/ndk/downloads/index.html
https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/Still it complains of c++14. Looks like the c++14 config enabled in .pro file is not really getting carried into gcc when compilation is happening.
@Wieland . Did you compile that code from Qt creator ? -
Really strange. If you check toolchains folder of ndk r12, it looks to be on gcc 4.9
https://developer.android.com/ndk/downloads/index.html
https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/Still it complains of c++14. Looks like the c++14 config enabled in .pro file is not really getting carried into gcc when compilation is happening.
@Wieland . Did you compile that code from Qt creator ? -
@Wieland Can you pls share your .pro file please ?
Also, can you please confirm that you are using nkd r12 as it is downloaded from here ?
https://developer.android.com/ndk/downloads/index.htmlYou android tab of build & run settings in qt creator is pointing to android ndk r 12 ?
-
@Wieland Can you pls share your .pro file please ?
Also, can you please confirm that you are using nkd r12 as it is downloaded from here ?
https://developer.android.com/ndk/downloads/index.htmlYou android tab of build & run settings in qt creator is pointing to android ndk r 12 ?
@Rubin-Stove Arg, sry, there is a misunderstanding: I did not compile with the Android NDK but only the code I posted above for Linux x86_64 because I wanted to see which GCC version can handle shared mutex correctly.
-
@Wieland . Nevermind dude. I now fixed the error with your help. Thanks a lot man
-
Glad you solved it! Could you please post the solution? Might be useful to other users, too :-)
-
My code had another mistake which was causing the issue. I fixed it along with the config setting of C++14 in .pro file. Apart from this, following info would certainly hep others facing exactly the same issue.
Install clang toolchain as a stand alone binary. More info at
https://developer.android.com/ndk/guides/standalone_toolchain.html#wwcAlso, Gcc is about to phase out in r13 of ndk. So that might fix these kind of problems for good
https://news.ycombinator.com/item?id=10772826