Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio error with 'timespec' structure

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);
}
like image 288
Vijay Manohar Avatar asked Oct 14 '15 00:10

Vijay Manohar


1 Answers

Add this compiler flag:

-DHAVE_STRUCT_TIMESPEC
like image 129
user_0 Avatar answered Oct 02 '22 13:10

user_0