std::chrono incompatible with arm64

113 views
Skip to first unread message

seal2002

unread,
Dec 10, 2017, 10:16:37 PM12/10/17
to android-ndk
Hello,
I use std::chrono::microseconds for some stuff in my app. I got some errors with the compilation in arm64 with type use int64_t for some variables. After digging to android-ndk, I realize the type def of int64_t is long long for 32bit but only long in 64bit. I solve that by casting the return of std::chrono::microseconds to int64_t and the compile is fine. But I wonder it is safe to do that ? For long long and use cast to only long type ? Should android ndk check that ?
I use android-ndk-r15c on windows 10 64bit. I already check with android-ndk-r16 but seem it still the same.
Thanks,
seal

Dan Albert

unread,
Dec 10, 2017, 11:00:40 PM12/10/17
to android-ndk
Which STL?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/6b9f03e3-f8da-4def-88fe-cc535c8e1f03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

seal2002

unread,
Dec 10, 2017, 11:41:15 PM12/10/17
to android-ndk
Hi, I use llvm-libc++
sorry to missing that info

On Monday, December 11, 2017 at 11:00:40 AM UTC+7, Dan Albert wrote:
Which STL?

On Sun, Dec 10, 2017 at 7:16 PM, seal2002 <phann...@gmail.com> wrote:
Hello,
I use std::chrono::microseconds for some stuff in my app. I got some errors with the compilation in arm64 with type use int64_t for some variables. After digging to android-ndk, I realize the type def of int64_t is long long for 32bit but only long in 64bit. I solve that by casting the return of std::chrono::microseconds to int64_t and the compile is fine. But I wonder it is safe to do that ? For long long and use cast to only long type ? Should android ndk check that ?
I use android-ndk-r15c on windows 10 64bit. I already check with android-ndk-r16 but seem it still the same.
Thanks,
seal

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

seal2002

unread,
Sep 18, 2019, 11:07:53 AM9/18/19
to android-ndk
Hello again,

As I checked on C:\DevTools\Android\android-ndk-r19c\sysroot\usr\include\stdint.h

#if defined(__LP64__)
typedef long __int64_t;
typedef unsigned long __uint64_t;
#else
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
#endif


I curious why we have define like this, as we will have some troubles with std lib which is return the plain data type as long long, int ... such as std::chrono ...
So only things we can avoid by cast them to the int64_t to avoid compiler error ?

Thanks,
Seal

mic _

unread,
Sep 18, 2019, 11:28:16 AM9/18/19
to andro...@googlegroups.com
Note that you can change the underlying type if you want to.

For example:

    using Microseconds = std::chrono::duration<int64_t, std::micro>;

Then use Microseconds where you would've used std::chrono::microseconds.

Reply all
Reply to author
Forward
0 new messages