【问题标题】:MinGW error "undefined reference to 'typeof''"MinGW 错误“未定义对 'typeof'' 的引用”
【发布时间】:2023-12-03 07:12:01
【问题描述】:

我得到一个“对'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”。

【问题讨论】:

    标签: c gcc mingw linker-errors c99


    【解决方案1】:

    通过将选项 -std=c99 传递给 GCC,您要求它根据不支持 typeof 关键字的 C99 标准进行编译。

    您可能想改用-std=gnu99

    【讨论】:

    • 或使用备用关键字__typeof__,无论标准遵从模式如何,它都有效。