Precompiled headers and General Parsing of Header File

Noel Yap nyap@garban.com
Thu Jul 30 06:00:00 GMT 1998


Kevin Atkinson wrote:
> ...
> template <class X>
> void long_func (X a, X b) {
>   /* very vert long defination
>    ...
>    ...
>    ...
>    ...
>    ...
>   */
> }
> 
> When reading the above code for the first time the compiler will just take the
> inner code and put it into one large block with out parsing it at all (unless
> to check for nested {} and } in quotes).
> 
> It will then be parsed only when it is instantiated.
> 
> This to me would seam to save a lot of time when a lot of unused templates are
> included in the header file like with SGI STL.

It'll also place any compiler warnings/errors where the template is
used, not where it's defined.  I would probably want warnings/errors to
be signalled where the template is being used and have it point back to
where it's defined (like any conflicting definitions of
variables/functions).

Noel



More information about the Gcc mailing list