error C2011: “timespec”:“struct”类型重定义


error C2011: “timespec”:“struct”类型重定义

C++ pthread pthread.h 中的 timespec 和time.h 中的 结构定义重复了 ,同时两个头文件中的条件编译条件不同,所以造成结构重复定义,简单快速见效的解决方法就是注释pthread.h 头文件中的struct timespce 定义

 warning C4477: “printf”: 格式字符串“%d”需要类型“int”的参数,但可变参数 1 拥有了类型“pthread_t”

 

print 中 传入pthread_t类型时报类型不匹配;

 

#include <stdio.h>
#include <iostream>
#include <Windows.h>
//#define HAVE_STRUCT_TIMESPEC 1;
#include <pthread.h>
//#include <>

//using namespace std;

#pragma comment(lib,"pthreadVC2.lib")




void *Function_T(void* Parm)
{
    pthread_t myid = pthread_self();
    while (1)
    {
        printf("线程ID=%lld \n", myid);
        //cout << "he" << endl;
        Sleep(6000);
    }
    return NULL;
}


int main(int argc, const char *argv[])
{
    pthread_t pid;
    pthread_create(&pid, NULL, Function_T, NULL);

    while (1)
    {
        printf("in fatherprocess!\n");
        Sleep(2000);
    }
    getchar();
    return 1;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM