Std :: round is not a member of std on android

I am using std::round from C ++ 11 in a Qt application for Android and iOS. But on android, I get an error that std::round is not a member of std , despite the inclusion of the cmath header.

How can I make std::round work with Android? Is there an alternative to std::round ?

The following is my Android environment:

 ANDROID_NDK_PLATFORM = android-23 NDK version = r13b ANDROID_NDK_TOOLCHAIN_VERSION = 4.9 
+6
source share
2 answers

It appears that some of the functions from the cmath header are missing from the Android-NDK, see here for more details.

However, it is very simple to implement your own round function:

 template<typename T> T round(T v) { return int(v + 0.5); } 

Or check out other suggestions / implementations here .

+2
source

How can I make std :: round work on android?

You can upgrade to NDK r16 beta 1 because this problem is fixed in this version.

+1
source

Source: https://habr.com/ru/post/1015273/


All Articles