Code Generator: usage of the #line directive

Flop Bucket
Fri Mar 30 14:18:00 GMT 2007

>I have written a code generator which takes an XML document and
>generate a C++ file. The XML document contains text element which
>contains C++ code. I would like to be able to locate error message
>based on the start of the text element. I think the #line directive

Hmm, sorry, not going to work.  #line is used to give the compiler a hint as 
to how many lines of source code to expect, this way it can size its caches 
and do memory allocations up front, thereby decreasing compile time.

On my current project, we have 583,250 lines of C++.  With out a #inline, it 
compiles in 12min 43 seconds, but if I insert a #line 600000 compile time 
drops to 7min flat.

You should do some research on memory allocation, it is known in 
professional circles to be one of the more "expensive" activities your code 
can do.  Also fragmentation can occur, but that is beyond the scope of this 

Exercise your brain! Try Flexicon.

More information about the Gcc-help mailing list