extern int TestVar;
in the header, and then instantiate it in ONE of the test.cpp files (there should be a .cpp file that 'goes along' with the header).
int TestVar = 1;
This is standard C, not related to VC specifically.
Rock
extern int TestVar;
in the header, and then instantiate it in ONE of the test.cpp files (there should be a .cpp file that 'goes along' with the header).
int TestVar = 1;
This is standard C, not related to VC specifically.
Rock
test1.obj : error LNK2005: _GUID_CustomForce already defined in dxfunctions.obj
Thanks for your previous reply Rock, anyone got any fixes for this now?
code:// Test1.h#ifndef _TEST1_H_INCLUDED#define _TEST1_H_INCLUDED// your code#endif
Maybe this helps.
Rock
Anyways, you should be able to include the dx headers in your own headers without trouble. Without seeing your file, I couldn't say what the problem is. You aren't instatiating the var in both the cpp files, right? However its being done, the var is getting compiled into both the obj files, hence the 'already defined' error. The only ways that it could happen is that it is instantiated in a header file, and thereby a copy is defined in every obj file that includes that header (my 1st reply). Or you have manually instantiated the var in multiple cpp files.
Rock
I'm looking at some of the examples that came with the SDK, and they're headers seem to use variable names like "LPDIRECTDRAW7" WITHOUT calling the header first, how is this possible!?
testheader.h
------
#if !defined(ATESTHEADER)
#define ATESTHEADER
int TestVar = 1;
#endif
test1.cpp
---------
#include "testheader.h"
// yup, just one line
test2.cpp
---------
// Appropriate standard includes here...
#include "testheader.h"
main()
{
cout << TestVar << endl;
getch();
}
Well, that's a summary of the code, here's the error I get...
test2.obj : error LNK2005: "int TestVar" (?TestVar@@3HA) already defined in test1.obj
I guesse it has something to do with globally defined variables in header files that are include in more than one other file. Well, any help would be nice, as I'd like to get this code working soon, thanks!
Vore
Good luck
Starfall