zoukankan      html  css  js  c++  java
  • 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 
    ", 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!
    ");
            Sleep(2000);
        }
        getchar();
        return 1;
    }

  • 相关阅读:
    【计算机网络】SSL交互和握手过程
    【LDAP】ldap目录服务的命名模型
    运维知识体系概览
    linux安装Django 以及 生产环境部署实现高并发
    xss过滤代码
    python单列模式
    JSONP
    组合搜索
    KindEditor
    登录验证码
  • 原文地址:https://www.cnblogs.com/ruiy/p/9705613.html
Copyright © 2011-2022 走看看