Hi,
I have a globals header that contains all my global variables and constants. The basic layout looks like this:
Code:
#ifndef _GLOBALS_H_
#define _GLOBALS_H_
int foo;
const int bar = 2;
#endif
Obviously I include this header in a lot of different files. The loader is complaining that there are multiple definitions of bar but does not complain about foo. The problem is obviously that I'm including globals.h in two different files, but if I add static in front of const int bar, doesn't that create separate global variables for the two different files? Also, why doesn't the loader complain about foo being defined multiple times? Thanks in advance.
EDIT: Fixed typo.