I want to use a macro defined in one c file into another c file.
For example if file a.c looks like:
#define TEN 10
So Now if i want to use TEN in b.c how can i do it?
I want to use a macro defined in one c file into another c file.
For example if file a.c looks like:
#define TEN 10
So Now if i want to use TEN in b.c how can i do it?
You would have to #include a.c in b.c. But that is not considered good practice. A better alternative would be to move the #define to a header file and include that header in both a.c and b.c. Another solution if you cannot move the #define would be just to duplicate it inside b.c. This is a maintenance headache, but if it is unlikely to change and you can't move it to a header it's not so bad.
BTW, there is a separate forum for C questions, so questions like these would go better in there. If this were C++ I'd say don't use a #define.
#include "myfile.h"
not
#include <myfile.h>
for user-made header files.