TIMESPEC:结构类型错误C2011 [英] Timespec :struct type Error c2011
本文介绍了TIMESPEC:结构类型错误C2011的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在执行使用Visual Studio 2015.I在C程序的Pthread了以下错误
错误C2011'的timespec':'结构'类型重新定义
以下是我的code:
#包括LT&;&pthreads.h中GT;
#包括LT&;&stdlib.h中GT;
#包括LT&;&stdio.h中GT;
void *的计算器(无效*参数);INT主(/ *为int * ARGC,CHAR *的argv [] * /)
{
的pthread_t thread_obj;
pthread_attr_t thread_attr;
字符* First_string =ABC/ *的argv [1] * /;
pthread_attr_init(安培; thread_attr);
在pthread_create(安培; thread_obj,&放大器; thread_attr,计算器,First_string);}
void *的计算器(无效*参数)
{
INT X =的atoi((字符*)参数);
的printf(x =%d个,X);
}
解决方案
添加这个编译器标志,必须解决(为我工作有同样的问题):
-DHAVE_STRUCT_TIMESPEC
While executing a Pthread program in C using Visual Studio 2015.I got the following error
Error C2011 'timespec': 'struct' type redefinition
The following is my code:
#include<pthread.h>
#include<stdlib.h>
#include<stdio.h>
void *calculator(void *parameter);
int main(/*int *argc,char *argv[]*/)
{
pthread_t thread_obj;
pthread_attr_t thread_attr;
char *First_string = "abc"/*argv[1]*/;
pthread_attr_init(&thread_attr);
pthread_create(&thread_obj,&thread_attr,calculator,First_string);
}
void *calculator(void *parameter)
{
int x=atoi((char*)parameter);
printf("x=%d", x);
}
解决方案
Add this compiler flag, must solve (worked for me with same problem):
-DHAVE_STRUCT_TIMESPEC
这篇关于TIMESPEC:结构类型错误C2011的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文