因此,在升级到Linux Mint(并使用GCC v4.7.3)时,一些标头已经产生了一些非常奇怪的编译器错误。当我尝试编译时,我收到以下错误消息:
gcc s.c
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/include/setjmp.h:26:0,
from /usr/lib/gcc/x86_64-linux-gnu/4.7/include/bits/pthreadtypes.h:14,
from /usr/lib/gcc/x86_64-linux-gnu/4.7/include/pthread.h:14,
from s.c:2:
/usr/lib/gcc/x86_64-linux-gnu/4.7/include/bits/setjmp.h:30:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/include/bits/pthreadtypes.h:14:0,
from /usr/lib/gcc/x86_64-linux-gnu/4.7/include/pthread.h:14,
from s.c:2:
/usr/lib/gcc/x86_64-linux-gnu/4.7/include/setjmp.h:46:5: error: unknown type name ‘__jmp_buf’
Compilation exited abnormally with code 1 at Mon Nov 25 09:03:37
所以这是触发编译器错误的标头:
/* Define the machine-dependent type `jmp_buf'. x86-64 version. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
#include <bits/wordsize.h>
# if __WORDSIZE == 64
typedef long int __jmp_buf[8];
# else
typedef int __jmp_buf[6];
# endif
#endif /* bits/setjmp.h */
这是源代码(s.c):
#include <stdio.h>
#include <pthread.h>
int main()
{
return 0;
}
这里发生了什么?
答案 0 :(得分:0)
所以我用谷歌搜索了“linux pthreadtypes”,发现另一个版本的代码点woboq dot org是Linux特有的。它编译得很好所以我擦除了现有版本的标题,它给了我之前发布的错误。不知道我从哪里获得该版本,但它在互联网上的某个地方,很可能是FreeBSD版本.Gotta确保你的POSIX线程头/库与你的操作系统兼容。