Advertisement

Header Files & #include's

Started by June 18, 2002 11:40 AM
6 comments, last by CoderX 22 years, 5 months ago
I have a project going where I made 1 mega header file that has all globals, function headers and other stuff that all source files of the project need. My question has to do with the #include directive. I get linker errors when I put all the #includes in the header file so I grabbed a project off the net and checked how they did it. It seems that they added all #includes for each source file and there are no #includes in any header file at all. Is this how I am supposed to do this as well? Or is there a way that I can make my one header file do all the #includes instead of each source file doing it? I get linker errors when working with #include <ddraw.h>, and I dont get any linker errors otherwise, so is this just a ddraw problem? Thanks.
++postcount;
I don''t use ddaw but some files require you to give linker options to include certain needed files.
Advertisement
I did add these to my link options in Project->Settings:
winmm.lib dinput.lib dxguid.lib dxerr8.lib ddraw.lib


And my project works if I have #include <ddraw.h> in the source file that uses directx stuff, but the problem now is that I need another source file to use ddraw stuff, and rather than adding another #incldue in that source file as well, I want to make it universal, if I could. Thanks though.
++postcount;
a.) Read the docs, particularly for direct draw. They''ll explain what else you need to use them.

b.) Read Kylotan''s article on organizing C and C++ files. It''s in the Articles and Resources->Previously Featured Articles section.
I see a lot of people forget to include dxguid.lib. I think a few times I''ve noticed in MSDN it wasn''t mentioned for functions that required its linkage. That''s probably your problem.

And it won''t hurt to read the article on the linker anyways. The linker is very powerful, and its something everybody should understand; not just be able to use.

- Kevin "BaShildy" King
Game Programmer: DigiPen
www.mpogd.com
- Kevin "BaShildy" KingGame Programmer: DigiPenwww.mpogd.com
Thanks for the article. I did read that article by ''Kylotan'' an year ago, when I just started out doing C++ and programming in general. But I guess I really wasn''t paying attention, and now that I read it again, it seems much more clear. Aha, this is an awesome site. Many thanks, oh yea, I setup my header and #includes now that it seems to work fine.
++postcount;
Advertisement
Doesnt dxguid.lib have to go first?
quote: Original post by DangerD
Doesnt dxguid.lib have to go first?

No. It''s if you choose to use #define INITGUID that it has to go first.

This topic is closed to new replies.

Advertisement