We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello everyone, I'm trying to split the C source code of one file into nearly 10 different. It does not work properly due to global variables declared in one header file but used in more than one C files. Compiling of such a project works fine but the linking errors L104 and L118 occur. My question: How can I prevent this errors without creating one header file for every C file? My idea is the following, but it is complicated and additionally unsure if it works:
#ifdef CPVAR extern unsigned char global_var1; extern unsigned int global_var2; extern unsigned long global_var3; #elseif unsigned char global_var1; unsigned int global_var2; unsigned long global_var3; #define CPVAR #endif
Take a look at the following knowledgebase article for several other ideas about how to do this: http://www.keil.com/support/docs/1868.htm Jon
Problem is solved. Thank you guys!
"Managing software engineers is like trying to herd cats" -Anonymous silicon valley manager
"Managing software engineers is like trying to herd cats" But what if the result is the cat's miauw? Erik