Can you extern a #define variable in another file?

user1295872 picture user1295872 · Apr 29, 2013 · Viewed 32.9k times · Source

For example abc.c contains a variable

#define NAME "supreeth"

Can extern the variable NAME in def.c?

Answer

MOHAMED picture MOHAMED · Apr 29, 2013

You can not use extern with macro. but if you want your macro seen by many C files

put your macro definition

#define NAME "supreeth"

in a header file like def.h

then include your def.h in your C code and then you can use your macro in your C file in all other C file if you include def.h