passes of the Preprocessor //

O

onkar

#include<stdio.h>
#define string(x) #x
#define replace(x) string(x)
#define var Hello
int main(int argc,char **argv){
char *str=replace(var);
printf("%s\n",str);
return 0;
}

This will print :
Hello

Ok fine , but can any one explain me how the preprocessor does it ?? In
one pass on multiple passes .The answer will be invaluabe to me.

regards,
Onkar
 
K

Keith Thompson

onkar said:
#include<stdio.h>
#define string(x) #x
#define replace(x) string(x)
#define var Hello
int main(int argc,char **argv){
char *str=replace(var);
printf("%s\n",str);
return 0;
}

This will print :
Hello

Ok fine , but can any one explain me how the preprocessor does it ?? In
one pass on multiple passes .The answer will be invaluabe to me.

As far as I know, most preprocessors work in one pass, but why does it
matter? It works as defined by the standard (if it's not buggy); what
more do you really need to know?

(There's certainly nothing wrong with curiosity, but you said the
answer will be invaluable.)
 
R

raxitsheth2000

if you are using gcc, then there is -E option that will only Stop after
Pre-Comilation.
after that you can view the output file.


--raxit
 
R

Richard Heathfield

onkar said:
#include<stdio.h>
#define string(x) #x
#define replace(x) string(x)
#define var Hello
int main(int argc,char **argv){
char *str=replace(var);
printf("%s\n",str);
return 0;
}

This will print :
Hello

Ok fine , but can any one explain me how the preprocessor does it ?? In
one pass on multiple passes .The answer will be invaluabe to me.

http://c-faq.com Answer 11:17 explains this.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top