我想使用数学库编译一个简单的 C90 代码:
主.c:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
printf("M_PI: %f\n", M_PI);
}
我使用 GCC 编译器并使用选项 -ansi -pedantic 来强制执行 C90 标准。
gcc -ansi -pedantic -lm main.c
但它不编译。以下是错误信息:
main.c: In function ‘main’:
main.c:7:25: error: ‘M_PI’ undeclared (first use in this function)
main.c:7:25: note: each undeclared identifier is reported only once for each function it appears in
我的问题是,为什么?C90标准是否禁止使用数学库?