472,347 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,347 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 1802
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,...
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...
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)...
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...
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...
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...
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)...
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...
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...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.