|
-
December 23rd, 2002, 08:40 PM
#1
#IFNDEF Preprocessor problem...HELP!
I dont get it. I'm using MS VC++ 6 and have create 2 .CPP files and a single .H header file. Both .CPP files include the header file. The header file's contents are as follows:
---
#ifndef __FOGHORN__
#define __FOGHORN__
int x;
#endif
---
On compiling i get the error message:
---
file2.obj : error LNK2005: "int x" (?x@@3HA) already defined in file1.obj
Debug/file1.exe : fatal error LNK1169: one or more multiply defined symbols found
---
It seems the #IFNDEF preprocessor directive isnt functioning. Or maybe Im thinking it supposed to do something it's not. When I use the #IFNDEF/#DEFINE as I do in the header above isnt the preprocessor supposed to "remember" the new #DEFINE across the scope of the entire compiling process for all files in the project so that when the same #include file is included in another .CPP file the contents of the #IFNDEF/#ENDIF will NOT be included affectively avoiding an "already included" linking error? Or is it only effective during the compiling of a single .CPP file then when compiling begins for another the preprocessor clears its table starting fresh?
Is this how it works??
Last edited by quantass; December 23rd, 2002 at 08:49 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|