简体   繁体   中英

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.

H:\C\sandBox.c|11|warning: implicit declaration of 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.

Change:

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

to

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

You forgot define :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM