这个错误要怎么办 unknown type name 'clock_t' - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
angel725
V2EX    问与答

这个错误要怎么办 unknown type name 'clock_t'

  •  
  •   angel725 2018-10-05 17:21:54 +08:00 4607 次点击
    这是一个创建于 2567 天前的主题,其中的信息可能已经有所发展或是发生改变。
    [zz@localhost trunk]$ x86_64-w64-mingw32-gcc word2vec.c -o word2vec.exe word2vec.c:19:10: error: #include expects "FILENAME" or <FILENAME> #include pthread.h ^ word2vec.c:46:1: error: unknown type name 'clock_t' clock_t start; ^ word2vec.c: In function 'TrainModelThread': word2vec.c:368:3: error: unknown type name 'clock_t' clock_t now; ^ word2vec.c:381:63: error: 'CLOCKS_PER_SEC' undeclared (first use in this function) word_count_actual / ((real)(now - start + 1) / (real)CLOCKS_PER_SEC * 1000)); ^ word2vec.c:381:63: note: each undeclared identifier is reported only once for each function it appears in word2vec.c: In function 'TrainModel': word2vec.c:547:3: error: unknown type name 'pthread_t' pthread_t *pt = (pthread_t *)malloc(num_threads * sizeof(pthread_t)); ^ word2vec.c:547:20: error: 'pthread_t' undeclared (first use in this function) pthread_t *pt = (pthread_t *)malloc(num_threads * sizeof(pthread_t)); ^ word2vec.c:547:31: error: expected expression before ')' token pthread_t *pt = (pthread_t *)malloc(num_threads * sizeof(pthread_t)); ^ word2vec.c:556:84: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, TrainModelThread, (void *)a); ^ 
    [zz@localhost trunk]$ x86_64-w64-mingw32-gcc word2vec.c -o word2vec.exe word2vec.c:46:1: error: unknown type name 'clock_t' clock_t start; ^ word2vec.c: In function 'TrainModelThread': word2vec.c:368:3: error: unknown type name 'clock_t' clock_t now; ^ word2vec.c:381:63: error: 'CLOCKS_PER_SEC' undeclared (first use in this function) word_count_actual / ((real)(now - start + 1) / (real)CLOCKS_PER_SEC * 1000)); ^ word2vec.c:381:63: note: each undeclared identifier is reported only once for each function it appears in word2vec.c: In function 'TrainModel': word2vec.c:556:84: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, TrainModelThread, (void *)a); ^ 

    第一次在 centos 下编译 exe。

    出现这种错误,不知道怎么办??

    直接 make 出来的,可以运行。但我想要在 win 下的。

    谢谢

    第 1 条附言    2018-10-05 20:12:52 +08:00

    有pthread.h

    [zz@localhost trunk]$ x86_64-w64-mingw32-gcc word2vec.c -o word2vec.exe word2vec.c:46:1: error: unknown type name 'clock_t' clock_t start; ^ word2vec.c: In function 'TrainModelThread': word2vec.c:368:3: error: unknown type name 'clock_t' clock_t now; ^ word2vec.c:381:63: error: 'CLOCKS_PER_SEC' undeclared (first use in this function) word_count_actual / ((real)(now - start + 1) / (real)CLOCKS_PER_SEC * 1000)); ^ word2vec.c:381:63: note: each undeclared identifier is reported only once for each function it appears in word2vec.c: In function 'TrainModel': word2vec.c:556:84: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, TrainModelThread, (void *)a); ^ 

    这是加了pthread.h后的错误。

    4 条回复    2018-10-06 08:53:37 +08:00
    visitant
        1
    visitant  
       2018-10-05 17:52:13 +08:00 via iPad
    看起来是需要链接 pthread 库啊,windows+pthread 搜索一下吧
    visitant
        2
    visitant  
       2018-10-06 01:33:34 +08:00 via iPad
    clock_t 这个类型好像在标准库里就有,试下包含 windows.h 头文件,而且直接在 win 下编译不好吗,非要交叉编译不可?
    msg7086
        3
    msg7086  
       2018-10-06 04:35:30 +08:00
    其实我还是建议你先在 Windows 版的 mingw 里试试……
    shiyouming91
        4
    shiyouming91  
       2018-10-06 08:53:37 +08:00 via iPhone
    include time.h 了么?
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     914 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 20:07 PVG 04:07 LAX 13:07 JFK 16:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86