Advertisement Jump to content
Sign in to follow this  
Monkeynuts

Force project files to inlude a header

This topic is 1862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I have a project with a config.h file that controls several things in my source. I want to make sure that all my files include it. Sometimes I forget to include it in new files, which means that things that were supposed to be conditionally compiled get compiled when they shouldn't and vice-versa, and that creates all kinds of problems. Sometimes it takes a while to trace the problem back to the fact that I forgot the include.

 

Is there any way to make sure that all my files include a certain header file? My code gets compiled by gcc, clang and visual c++, and I'd relly prefer a cross-compiler and build system solution to this.

 

 

Share this post


Link to post
Share on other sites
Advertisement
I don't know about the others, but in Visual Studio, you can use the "force include file" option in the project properties under C/C++ > Advanced.

Share this post


Link to post
Share on other sites

I'm actually using defines passed to the build system right now to configure my builds. I was going to migrate to a config file instead, to have all defines in a common place (together with nice comments and explanations). However, now that you mention it, that will probably be more of a headache when building for different platforms.

 

I like the second approach (and I've seen this in use, but never realized that it will actually help me by making sure I get compile time errors when appropriate - that's what happens when you just read something and don't use it yourself : )).

 

Thanks for the explanation and for expanding my views on this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!