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

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值