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!
What is the best method to declare some variables global ( more than one .C File should know it ) and still avoid multiple public definitions?
A Global Header File is definitely NOT the key to success ;-)
Thanks for your help!
myinclude.h
#ifndef _MYINCLUDE_H #define _MYINCLUDE_H #ifdef MAIN #define EXTERN #else #define EXTERN extern #endif EXTERN int my_variable; #endif _MYINCLUDE_H
main.c
#define MAIN #include "myinclude.h" ...
other.c
#include "myinclude.h" ...