if i define a namespace in file 1, and #include file 1 in file 2, how do i access the namespace in file 3... when you would use extern if it were a normal variable.
if i define a namespace in file 1, and #include file 1 in file 2, how do i access the namespace in file 3... when you would use extern if it were a normal variable.
hmm... why not just include file 1 in file 3?
If you have header guards in file 1 there should not be a problem.
i tried that but i get a linker error saying that a variable is already defined.Originally posted by laserlight
hmm... why not just include file 1 in file 3?
If you have header guards in file 1 there should not be a problem.
What header guards means is in your header header.h addOriginally posted by laserlight
hmm... why not just include file 1 in file 3?
If you have header guards in file 1 there should not be a problem.
This way the header content will be included only once.Code:#ifndef HEADER_INCLUDED #define HEADER_INCLUDED -- the header file #endif
Your header file should not define any variables. Only define vars in the C/CPP files.Originally posted by olsmokey
i tried that but i get a linker error saying that a variable is already defined.
If a variable needs to be available in more than one C file, the header can specify the variable as extern. It will then be available to all modules.
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers