编译C ++ code在Android的NDK线程时与memset的错误 [英] Error with memset when compiling c++ code for threads in android ndk

查看:645
本文介绍了编译C ++ code在Android的NDK线程时与memset的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。我想创建的Andr​​oid 2.3.4线程与NDK R7。当我编译这个code:

 的#include< stdio.h中>
#包括< stdlib.h中>
#包括< string.h中>
#包括<文件math.h>
#包括system.h中
#包括< jni.h>
#包括< pthreads.h中>

unsigned int类型的CreateThread(void *的函数(无效*),void *的背景下)
{INT RET;
    的pthread_t线程;
    RET =在pthread_create(安培;螺纹,NULL,功能,环境);
    如果(RET!= 0)
    {返回0;
    }
    返程(无符号整数)线程;
}
 

我收到以下错误消息:

<$p$p><$c$c>E:/$c$c/Android/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include/stdarg.h:102:错误:预期';' 类型定义前 在文件中包括来自E:/ code /安卓/ Android的NDK-R7 /平台/ Android为14 /弓臂/ usr / include目录/ pthreads.h中:32,从JNI / system.cpp:13: E:/ code /安卓/ Android的NDK-R7 /平台/ Android为14 /弓臂/ usr / include目录/ signal.h中:在函数'诠释sigemptyset(sigset_t *)': E:/ code /安卓/ Android的NDK-R7 /平台/ Android为14 /弓臂/ usr / include目录/ signal.h中:84:错误:'memset的在此范围内未声明 E:/ code /安卓/ Android的NDK-R7 /平台/ Android为14 /弓臂/ usr / include目录/ signal.h中:在函数'诠释sigfillset(sigset_t *)': E:/ code /安卓/ Android的NDK-R7 /平台/ Android为14 /弓臂/ usr / include目录/ signal.h中:90:错误:'memset的在此范围内未声明

我错过了包括或定义的东西拿到memset的错误?

我真的不知道是什么问题,为什么memset的错误apear。我也试过,包括为c_string但后来我得到了一个巨大的错误数。

解决方案

我发现这个问题。我有我自己的类,有一个名为string.h中,并驻留在我的JNI目录中的文件名。因此,string.h中驻留在NDK内并具有必需的memset函数的声明(等等)不被包括在内。

选项是要么改变我的课的文件名/名称或直接包括了直接路径的NDK的string.h中。

我选择了第一个选项,并改名为我的字符串类,尽量不使用标准的文件名我的课从现在开始......

I have a Problem. I want to create a thread in Android 2.3.4 with the NDK r7. When I compile this code:

#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;
}

I get these error messages:

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

Did I miss to include or define something to get the memset errors ?

I am really not sure what the problem is and why the memset errors apear. I also tried including cstring but then I got a huge number of errors.

解决方案

I found the problem. I have my own class that has a filename that is called "string.h" and resides within my jni directory. Therefore the "string.h" that resides within the ndk and has the declaration of the necessary memset function (among others) is not being included.

The options were to either change the filename/name of my class or directly include the string.h from the ndk with a direct path.

I chose the first option and renamed my string class and try to not use standard file names for my classes from now on...

这篇关于编译C ++ code在Android的NDK线程时与memset的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆