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

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top