GCC & precompiled headers question

Hedayat Vatankhah hedayat at grad.com
Sun May 9 19:20:54 UTC 2010


On ۱۰/۰۵/۰۶  03:34, Christoph � wrote:
> Hi all,
> this is an off topic question, but since I know that some of you are
> familiar with gcc, I am asking it here before signing up somewhere else.
> I have to source-compile one language (Modelica) to C++. Since Modelica
> has a structural subtype system, I'd like to create classes that way:
> //Modelica
> class Foo
> 	Real x;
> end Foo;
> //C++
> template<Foo_Real>  class Foo {
> 	Foo_Real x;
> }
> That means every generated class (and function for that matter) is
> (parametric) polymorphic and can be reused in other compilation units
> for subtypes. Unfortunately that also means, that I can only generate
> headers and no libraries or object files. Basically g++ plays the role
> of a linker for modelica. But this means that g++ will parse, check and
> compile every header again and again even if it's clear (at least after
> the first pass) that the code is sane.
> I've learned that the C++ standard delivers the export keyword to
> include template symbols in object files, but g++ does not support this.
> The closest thing I've seen to export would be precompiled headers.
> Unfortunately g++ also allows one single precompiled header per
> compilation unit. Does anyone know why? And is there any way to speed up
> the "linking" process a little (like letting g++ at least preprocess the
> headers or something like this)?
Have a look at gcc info: C++ Extensions->Template Instanciation. You can 
go with the first method: using -frepo but notice that it doesn't work 
when ccache is enabled. So, you can export CCACHE_DISABLE=1 before 
running gcc with -frepo option. Also, I think you can go with a solution 
using export keyword too (the second method).

Good luck,
> thanks for any comments,
> Christoph

More information about the devel mailing list