【发布时间】:2021-10-28 02:30:59
【问题描述】:
我有以下代码:
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
char r[15];
double radius;
double SphereVolume(double radius){
double volume;
volume = (4.0 / 3.0) * (M_PI) * (pow(radius, 3.0)); ///'identifier "M_PI" is undefined'
return (volume);
}
int main()
{
/* gets input from the user */
printf("What is the radius of the Sphere? ");
fgets(r, sizeof(r), stdin);
sscanf(r, "%lf", &radius);
printf("Volume of the sphere is %f", SphereVolume(radius));
return (0);
}
我可以用 gcc 很好地运行它:
$> gcc -Wall -Werror -Wextra -o SphereVolume SphereVolume.c -lm
但是 VS Code 甚至不允许我调试代码。怎么了?我是不是搞砸了设置?
【问题讨论】:
-
“连调试代码都不让我” 这和你得到的宏相关的错误无关,但是不知道细节很难说别的。
-
M_PI不是标准宏。毫不奇怪,这里缺少它,因为代码没有定义它。
标签: c visual-studio-code vscode-extensions vscode-debugger