C/Global variables
Expert: Prince M. Premnath - 6/3/2007
QuestionHi!
I would like to know how can I declare a global variable in a header file. I have a project which includes 2 files (main.c and aux.c) and a common header file (define.h) that looks like this:
#ifndef _VAR
#define _VAR
/* global variables */
int number1, number2;
#endif
but when I try to make and exe file the linker shows me an error:
number1 defined in module main.c is duplicated in module aux.c
and it's the same with number2,
so, how can I solve this? I need this global variables.
I work with turboc++ 1
Thanks in advance.
AnswerDear Mr Updt
Here i didn't find any problem with this header file , But i want the code for main.c and aux.c , make sure your project should have only one main module , and other header files and associated definition's will be linked further with that main module !
If you give me the code , hope it will be easy for me to spot the error
Thanks and regards
Prince M. Premnath