tags:

views:

326

answers:

3

Are precompiled headers supported on gcc 3.3.3 ?

If yes what is the syntax to generate and use precompiled headers on Linux with gcc 3.3.3. We crosscompile our projects on Windows and Linux, on Windows we precompile stdafx.h and I'm investigating how to set it up so that it is precompiled on Linux as well.

I'm aware of the gcc doc , I'm searching for the actual solution.

On gcc 3.3.3 I get this:

> gcc stdafx.h
gcc: compilation of header file requested

And last, if it worked what would be the name of generated file?

EDIT: Precompiled headers do not seem to be supported on gcc 3.3.3 and on newer gcc the generated file is named with .gch extension.

A: 

I'm not entirely sure if GCC 3.3 supports it, but precompiling headers is actually no different from producing objects, at least with GCC 4.x:

gcc $CFLAGS header.h

It'll produce a new precompiled header next to the .h file and automatically use it when it's #included.

greyfade
Would it generate the file as header.h.pch or something like that or header.o ?
stefanB
on gcc 3.3.3 I'm getting error so I suspect precompiled headers are not supported
stefanB
+2  A: 

I don't know from what version gcc supports it, but for how to use them just read the gcc documentation.

Anyway, gcc 3.3.3 is pretty old, too. Maybe there's a chance that you can upgrade to a more recent 4.X version? That should support recompiled headers.

Maybe you could try the latest 3.X GCC (GCC 3.4.6). I assume the ABI break is from 3.X to 4.X, so 3.4 may be compatible. I think it may be worth checking.

from http://gcc.gnu.org/gcc-3.4/changes.html

C/Objective-C/C++
Precompiled headers are now supported.

lothar
We have gcc 4.X but need to support older build because of 3rd party libraries so it's not our choice.
stefanB
If the latest 3.X GCC (GCC 3.4.6) is still ABI compatible with your 3rd party libs then moving to GCC 3.4.6 should help.
lothar
Seems like the note implies that precompiled headers are supported from gcc 3.4, thanks. No problem, I'll turn them on on gcc 4.x for now.
stefanB
A: 

I don't remember about if it is supported in gcc 3.3.3. The output file be {filename.ext}.gch

Anton Kazennikov