我有个问题。我想用NDK r7在Android2.3.4中创建一个线程。当我编译此代码时:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "System.h"
#include <jni.h>
#include <pthread.h>
unsigned int CreateThread(void* function(void*) , void * context)
{ int ret;
pthread_t thread;
ret = pthread_create(&thread, NULL, function, context);
if(ret != 0)
{ return 0;
}
return (unsigned int) thread;
}我收到以下错误消息:
E:/Code/Android/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include/stdarg.h:102: error: expected ';' before 'typedef'
In file included from E:/Code/Android/android-ndk-r7/platforms/android-14/arch-arm/usr/include/pthread.h:32, from jni/system.cpp:13:
E:/Code/Android/android-ndk-r7/platforms/android-14/arch-arm/usr/include/signal.h: In function 'int sigemptyset(sigset_t*)':
E:/Code/Android/android-ndk-r7/platforms/android-14/arch-arm/usr/include/signal.h:84: error: 'memset' was not declared in this scope
E:/Code/Android/android-ndk-r7/platforms/android-14/arch-arm/usr/include/signal.h: In function 'int sigfillset(sigset_t*)':
E:/Code/Android/android-ndk-r7/platforms/android-14/arch-arm/usr/include/signal.h:90: error: 'memset' was not declared in this scope我是不是错过了包含或定义一些东西来获取memset错误?
我真的不确定问题是什么,以及为什么memset错误出现。我也尝试了包含cstring,但是我得到了大量的错误。
发布于 2011-12-26 07:02:43
我找到问题了。我有一个自己的类,它的文件名是“string.h.h”,它驻留在我的jni目录中。因此,不包括驻留在ndk中并具有必要的memset函数(以及其他函数)的声明的“string.h.h”。
这些选项要么更改我的类的文件名/名称,要么使用直接路径直接包含ndk中的字符串.h。
我选择了第一个选项,并将我的string类重命名,并尝试从现在开始不对我的类使用标准文件名……
https://stackoverflow.com/questions/8630068
复制相似问题