Click to See Complete Forum and Search --> : Linkage Woes, I think extern is the problem


mags
July 31st, 2005, 11:52 AM
Im trying to make a simple wrapper class for the BOB structure from Tricks of the Windows Programming Gurus but Im having difficulties getting it to compile.

I have 3 files from the book and 2 files for my class. I can compile the 3 files from the book together fine, the problem arises when I try to compile my code with it. My compiler is flagging t3dlib1.h as the problem though even though it compiles with the other 2 files from the book fine without my 2 files.

My setup:
files from book->t3dlib1.h t3dlib1.cpp main.cpp

t3dlib1.h has all the header info,obviously hehe, and alot of externs at the end. T3dlib1.h contains no #includes. main.cpp has all the global directX7 objects and Im guessing from my limited usage of externs that the keyword is allowing this file to "see" the global objects.

t3dlib1.cpp has nothing out of the ordinary, it contains includes for t3dlib1.h and all the windows/directx/math headers.

main.cpp is where all the action is. DirectX is initialized here, has all the calback windows stuff, and has the game loop for my application. Main.cpp contains all the same includes as t2dlib1.cpp.

My files:
BaseSprite.h includes t3dlib1.h to get access to the structures defined there, without it <the include> t3dlib1.h compiles fine but basesprite.h is flagged for "identity not found" on structures that are defined in t3dlib1.h.

I hope Ive given enough information on my problem without being too overly confusing :P Im attaching all my source files aswell since they are pretty small in size.

mags
August 1st, 2005, 02:34 PM
<RESOLVED>

If anyone else ever has this problem this is what I did to resolve it.

I think the compiler was trying to link the basesprite class files before t3dlib1,which has the the structures needed by basesprite.h. To fix it I added all the includes to the .cpps instead of the headers, added <ddraw.h> to basesprite.cpp so it knew what the DDRAW structures were, and made sure to add #include T3DLIB1.h before #include BASESPRITE.H in all the .cpps.