MinGW错误“undefined reference to 'typeof'”

4

在编译和链接以下代码时,我遇到了“undefined reference to 'typeof'”错误:

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

int main() {
    typeof(5);
    return 0;
}

gcc版本为4.3.3,命令行是"gcc.exe -std=c99 1.c -o 1.exe"。

1个回答

4
通过向GCC传递选项-std=c99,您要求它根据C99标准进行编译,该标准不支持typeof关键字。您可能希望改用-std=gnu99

5
或者使用备用关键字 __typeof__,它可以在任何标准兼容模式下工作。 - ephemient

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接