[英]Use of macros but had implicit declaration of function error
I'm trying to run the following code, but I cannot compile it as my IDE complained for the following reason.我正在尝试运行以下代码,但我无法编译它,因为我的 IDE 抱怨以下原因。
H:\C\sandBox.c|11|warning: implicit declaration of function 'RECIPROCAL'|
H:\C\sandBox.c|11|警告:隐式声明 function 'RECIPROCAL'|
I don't know why my code doesn't work.我不知道为什么我的代码不起作用。 Can you please help?
你能帮忙吗?
#include <stdio.h>
# RECIPROCAL(number) (1.0 / (number))
int main()
{
float counter; /* Counter for our table */
for (counter = 0.0; counter < 10.0;
counter += 1.0) {
printf("1/%f = %f\n", counter, RECIPROCAL(counter));
}
return (0);
}
That's because you need to use #define
to define a preprocessor macro.那是因为您需要使用
#define
来定义预处理器宏。
Change:改变:
# RECIPROCAL(number) (1.0 / (number))
to至
#define RECIPROCAL(number) (1.0 / (number))
You forgot define
:你忘了
define
:
#define RECIPROCAL(number) (1.0 / (number))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.