HEllo everyone,
i did not find the forum for C programming, so i will post in here, because i try to use this code on my MSP430 processor, I hope this will also result in some answers :)
I have started using multiple *.c-files and therefore multiple *.h-files in my project. I have about 20 different files and everthing seemed to work just fine, now I did want to introduce a new global variable to all my files.
This variabel i placed in my say global.h file, in which all my global variables should one day lie.
[global.h]
unsigned int uint16_globaltest;
now in my other files i include this global-header:
[main.c] - [func.c] - [foo.c]...... as often as i want
#include "global.h"
extern unsigned uint16_globaltest;
Now i will get CCS error messages like: symbol "uint16_globaltest" redefined: first defined in "func.obj"; redefined in "./main.obj"
I did find out some soultions in the web like introduce some structure like:
[global.h]
#ifndef EXTERN
#define EXTERN extern
#endif
EXTERN unsigned uint16_globaltest;
And I suppode i will implement that and it should work, but here is my question:
In every header file the normal structure is:
#ifndef GLOBAL_H_
#define GLOBAL_H_
unsigned int uint16_globaltest;
#endif
Shouldnt this code already implement that the header file is ONLY declared ONCE and not more????
For me right now it seems, that the header is included in every single c-file, because I get the error messages with multiple variabel defines.
Could somebody tell me am I thinking wrong, or is something wrong with my compiler settings?
Thanks a lot,
Best wishes,
Seb