Hey,
I was trying to do some simple stuff using global variables but my main file was getting huge! I broke it up and I had like
main.cpp
Code:
int global1;
int global2;
int global3;
int main()
{
return 0;
}
and then blah.h
Code:
extern "C++"
{
int global1;
int global2;
int global3;
}
and then blah.cpp
Code:
#include "blah.h"
void blah() { /* uses globals */ }
Unfortunately though I get that the variables are already defined as if the extern declaration is a new definition!
Code:
1>------ Build started: Project: EmptyProject, Configuration: Debug Win32 ------
1>Compiling...
1>Events.cpp
1>Linking...
1>Events.obj : error LNK2005: "struct ID3DXMesh * g_pMesh" (?g_pMesh@@3PAUID3DXMesh@@A) already defined in EmptyProject.obj
...
1>Debug\EmptyProject.exe : fatal error LNK1169: one or more multiply defined symbols found
Is this not the right way to use extern? I thought that's how you refer to global symbols -- with extern?