Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there cross-platform precompiled header frameworks/methods in C++?

I'm wondering what others have experienced implementing cross-platform (linux and windows) precompiled headers in C++. I'm thinking of what Visual Studio lets you do with stdafx.h files that can drastically improve compile times for large amounts of C++ code by precompiling the common headers used across the board (std/boost/etc headers). Is there a way to make this happen cross platform with some kind of framework or something?

What kind of experience have you had trying to do this?

Edit

I don't really mean sharing the actual resulting pch, I'm more interested in frameworks that can generate pch and whatever the equivelant would be for, say, gcc, when compiled on that specific platform.

like image 991
Doug T. Avatar asked Dec 14 '25 19:12

Doug T.


1 Answers

gcc will automatically precompile headers if you pass a header file instead of an implementation file. Simply add the -x switch if it tries to produce object code. GCC will always look for the .gch file before the header, so it's simple enough to use. This page has more info. Add it to your Makefile to automate the process.

like image 146
greyfade Avatar answered Dec 16 '25 11:12

greyfade