473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

template and preprocessor

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
Jul 22 '05 #1
1 1846
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
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
2
by: spasmous | last post by:
I just found out MSVC++ doesn't unroll loops on any optimization setting. So I manually unrolled the inner loop of a slow part of my program... The result was a 2X gain in speed. So I'm wondering...
10
by: Clay_Culver | last post by:
I have heard that it is possible to use classes + template magic to make standalone functions (or maybe just a functor which acts like a function) which can accept variable length arguments without...
4
by: Howard Gardner | last post by:
// I think that there is no way to write the template "cant_write_me" in // this example. Would love to be wrong. // one of many approaches that won't work template< template< typename class...
4
by: pinkfloydhomer | last post by:
We might use the normal preprocessor something like this #define WIDTH 42 #define HEIGHT 100 #define AREA (WIDTH*HEIGHT) To have "42*100" is inserted in the code whereever AREA is used. But...
2
by: adrian.hawryluk | last post by:
Hi everyone, I've been using templates for a while, but I'm not at full power yet (knowledge=power) ;). Does anyone know where I can get information on this 'new' template usage? template<a...
5
by: kRyszard | last post by:
how to make the following code work: template<class TYPE> void f2(char *buffer, TYPE *outer) { // do something ... // ... #if (TYPE == int) *outer = atoi(buffer); #endif #if (TYPE == double)
5
by: iapx86 | last post by:
My parser project calls for a computed goto (see code below). The C preprocessor delivers the desired result, but is ugly. Template metaprogramming delivers results I do not understand. Can...
10
by: abir | last post by:
Hi, This is not strictly a C++ language question. Is there any way to form a string from an identifier with the preprocessor with some operations ? i.e to say to make a string from an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.