错误:使用不同类型的typedef重定义

时间:2017-03-21 10:37:15

标签: c++ android-ndk java-native-interface

我尝试使用NDK在Android Studio中编译c ++ lib并获得一些错误:

C:\AndroidSDK\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\..\lib64\clang\3.8.275480\include\stddef.h:62:23: error: typedef redefinition with different types ('unsigned long' vs 'unsigned int') typedef __SIZE_TYPE__ size_t; ^../../../../src/main/cpp/include\Crypto/Core/Types.h:20:22: note: previous definition is here typedef unsigned int size_t;

当我定义

typedef unsigned long size_t;

我明白了:

C:\AndroidSDK\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\..\lib64\clang\3.8.275480\include\stddef.h:62:23: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long') typedef __SIZE_TYPE__ size_t;^  ../../../../src/main/cpp/include\Crypto/Core/Types.h:20:23: note: previous definition is here typedef unsigned long size_t;

我该如何解决?

2 个答案:

答案 0 :(得分:1)

您无法使用typedef重新定义size_t。如果你想要一个32位无符号整数,你可以写:

typedef unsigned long u32t

答案 1 :(得分:1)

size_t已经是由多个C / C ++标准定义的数据类型。 尝试输入尚未在语言中定义的其他内容。

实施例: -

typedef unsigned long my_size_t;