开发者

Use of macros but had implicit declaration of function error

开发者 https://www.devze.com 2023-03-01 00:21 出处:网络
I\'m trying to run the following code, but I cannot compile it as my IDE complained for the following reason.

I'm trying to run the following code, but I cannot compile it as my IDE complained for the following reason.

H:\C\sandBox.c|11|warning: implicit declaration of function 'RECIPROCAL'|

开发者_JAVA百科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.

Change:

# RECIPROCAL(number) (1.0 / (number))

to

#define RECIPROCAL(number) (1.0 / (number))


You forgot define:

#define RECIPROCAL(number) (1.0 / (number))
0

精彩评论

暂无评论...
验证码 换一张
取 消