ICU编译Android的 - “uint64_t中”没有指定类型类型、ICU、Android、uint64_t

2023-09-05 00:28:55 作者:||紫禁★王者丿

在尝试交叉编译使用Android的NDK-R7在Linux的ICU,当我运行'制作'出现以下错误配置后

While attempting to cross-compile ICU using android-ndk-r7 in Linux, the following error occurs after configuration when I run 'make'

__/android-ndk-r7/platforms/android-8/arch-arm/usr/include/sys/types.h:124: error: 'uint64_t' does not name a type

SYS / types.h中>

这是由的#include&LT触发;在ICU /来源/普通/ UNI code / ptypes.h:25。这似乎是在Android的NDK-N7非ICU的问题。在sys / types.h中,我们看到

This is triggered by the #include <sys/types.h> in icu/source/common/unicode/ptypes.h:25. It appears to be a non-icu issue in android-ndk-n7. In sys/types.h we see

#ifdef __BSD_VISIBLE
typedef unsigned char   u_char;
typedef unsigned short  u_short;
typedef unsigned int    u_int;
typedef unsigned long   u_long;

typedef uint32_t       u_int32_t;
typedef uint16_t       u_int16_t;
typedef uint8_t        u_int8_t;
typedef uint64_t       u_int64_t;
#endif

的culprint这里是uint64_t中,这是在的#include中所定义; stdint.h&GT;在SYS / types.h中的顶部。在这里,我们看到

The culprint here is uint64_t, which is defined in #include <stdint.h> at the top of the sys/types.h. Here we see

#if !defined __STRICT_ANSI__ || __STDC_VERSION__ >= 199901L
#  define __STDC_INT64__
#endif

...

#if defined(__STDC_INT64__)
typedef __int64_t     int64_t;
typedef __uint64_t    uint64_t;
#endif

如果 STRICT_ANSI 或 STDC_VERSION 并因此 STDC_INT64 从不definied,包括SYS / types.h中会抛出一个错误,因为uint64_t中从未定义。任何code,后来要么调用的int64_t(重症监护室code发生)和uint64_t中也抛出了同样的错误。因为我这个临时的解决办法是定义的 STDC_INT64 在重症监护病房的ptypes.h中的#include&LT前右侧上方; SYS / types.h中取代。这是一个坏主意?

If STRICT_ANSI or STDC_VERSION and therefore STDC_INT64 are never definied, including sys/types.h will throw an error since uint64_t is never defined. Any code that later calls either int64_t (happens in icu code) and uint64_t will also throw the same error. My temporary fix for this is to define STDC_INT64 at the top of icu's ptypes.h right before #include <sys/types.h>. Is this a bad idea?

推荐答案

目前的主要问题是,uint64_t中是不是在C之前的版本C99定义的类型。 将它定义最好的办法就是告诉GCC哪种标准,你想使用。

The main issue is that uint64_t isn't a defined type in C versions prior to C99. The best way to have it defined is to tell gcc which standard you'd like to use.

对于C ++,这是传递 -std = GNU ++ 0x中标志。对于C,这是通过 -std = C99

For c++, that's passing the -std=gnu++0x flag. For C, that's passing -std=c99

即。添加一行类似

APP_CPPFLAGS= -std=gnu++0x

您Application.mk文件。

to your Application.mk file.

另外,你可以通过你的#define本事;我只是不会散发code这样的黑客,因为它是脆弱的。

Alternatively, you can just hack it via your #define; I just wouldn't distribute code with such a hack as it's fragile.