template and preprocessor

Discussion in 'C++' started by David Lindauer, Sep 25, 2004.

  1. suppose I have this:

    template <class T>
    class myclass {
    T a ;
    #ifdef PREPROC_SYMBOL
    T b;
    #endif
    } ;

    at what point do the preprocessor statements get interpreted? When the
    template is being compiled, or
    when the template definition is being invoked?

    Thanks,

    David
     
    David Lindauer, Sep 25, 2004
    #1
    1. Advertisements

  2. David Lindauer wrote:

    > template <class T>
    > class myclass {
    > T a ;
    > #ifdef PREPROC_SYMBOL
    > T b;
    > #endif
    > } ;
    > at what point do the preprocessor statements get interpreted? When the
    > template is being compiled, or
    > when the template definition is being invoked?


    The preprocessor, as his name says, is executed before compiling. In some
    systems is executed as a separate program and his output is directed to the
    "real" compiler. And even if the compiler does not work that way,
    habitually a separate preprocessor is available just in case you need to
    use it (cpp is a usual name for it).

    Then, when the template is compiled, all preprocessing has been done before.

    --
    Salu2
     
    =?ISO-8859-15?Q?Juli=E1n?= Albo, Sep 25, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.