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. Advertising

  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. Advertising

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.
Similar Threads
  1. Cronus
    Replies:
    1
    Views:
    658
    Paul Mensonides
    Jul 15, 2004
  2. snnn
    Replies:
    6
    Views:
    648
  3. kRyszard

    template #if preprocessor

    kRyszard, Aug 8, 2007, in forum: C++
    Replies:
    6
    Views:
    355
    James Kanze
    Aug 9, 2007
  4. mathieu
    Replies:
    8
    Views:
    457
    Alf P. Steinbach
    Aug 6, 2009
  5. mathieu
    Replies:
    1
    Views:
    525
    mathieu
    Aug 6, 2009
Loading...

Share This Page