Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use extern for macros?

Tags:

c

macros

extern

I know that functions are tagged extern in C by default and it is also possible to use an extern variable in C (if it is initialized in some other file or if I write extern int foo = 1;). But can I use extern for a C macro because they behave like functions?

like image 773
Vaibhav Agarwal Avatar asked Oct 09 '12 04:10

Vaibhav Agarwal


1 Answers

Unless something radically changed in C99, preprocessor macros don't have storage classes. You can't declare them without simultaneously defining them. They aren't even treated by the compiler in the same way that other identifiers are treated -- they're a purely textual translation that (at least conceptually) happens even before the compiler attempts any kind of name lookup.

like image 188
j_random_hacker Avatar answered Sep 21 '22 14:09

j_random_hacker