Reputation: 423
I am trying to use a preprocessor variable I declared in main.c in another C source file in the same project but I get a compile time error, included from main.c: undefined symbol 'mysymbol'. Now, what are the rules concerning the use of #define
out side the file in which it is contained?
Upvotes: 1
Views: 172
Reputation: 1929
You need to put the #define
in a header, and #include
it in all files where you want to reference it.
Upvotes: 3
Reputation: 182619
Now, what are the rules concerning the use of #define out side the file in which it is contained
A #define
is not visible outside its file. The only way to make it visible outside the file where it is defined is to include that file.
So it looks like you should put it in a header included by both main.c
and that other file.
Upvotes: 9