Header Files & #include's
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.
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.
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.
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
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;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement