Is there a way to structure precompiled headers in VS that doesn't make my code inconvenient to build in GCC?

In the past, I used pre-compiled headers in VC to speed up compilation time, but usually only in small projects, which basically represent a small directory of source code. Since VC ++ requires that all files contain the same header exactly regardless of the path (say, "foo.h", not "../foo.h"), everything gets hairy when you have different subdirectories source. If all my files are just

#include "foo.h" 

it works, but only when I have precompiled headers. To make this work in all cases, I need to make dummy foo.h files that go

 #include "../foo.h" 

It starts to get ridiculous pretty quickly, especially when you have several levels.

Although I usually prefer Microsoft tools, I have to say that the GCC system in which you manually compile the headers into .gch files is far superior to me. This is much less intrusive and does not require you to include all your headers in every compilation unit, which is ugly and slow if you build the compiler without pre-compiled headers.

Am I missing something in the VC version? None of the large projects that I worked on professionally used precompiled headers, and I want to make sure that I give them a decent shake before I give up and simply agree to a longer compilation time.

Is there a cleaner way to do this?

Thanks!

+4
source share
1 answer

Is it possible to update the path to the project, so there is no need to create a separate header. We used the Common / Common.h header file to create a precompiled header in all projects.

If the compilation time is a problem, different approaches may apply: we removed the precompiled headers from the project, since distributed compilation was much faster with them.

+2
source

Source: https://habr.com/ru/post/1343719/


All Articles