passes of the Preprocessor //

Discussion in 'C Programming' started by onkar, Nov 30, 2006.

  1. onkar

    onkar Guest

    #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
    onkar, Nov 30, 2006
    #1
    1. Advertising

  2. "onkar" <> writes:
    > #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.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Nov 30, 2006
    #2
    1. Advertising

  3. onkar

    Guest

    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
    onkar wrote:
    > #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
    , Nov 30, 2006
    #3
  4. 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.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
    Richard Heathfield, Nov 30, 2006
    #4
  5. onkar

    CBFalconer Guest

    wrote:
    >
    > 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.


    Don't top-post. See the following links.

    --
    Some informative links:
    <news:news.announce.newusers
    <http://www.geocities.com/nnqweb/>
    <http://www.catb.org/~esr/faqs/smart-questions.html>
    <http://www.caliburn.nl/topposting.html>
    <http://www.netmeister.org/news/learn2quote.html>
    <http://cfaj.freeshell.org/google/>
    CBFalconer, Nov 30, 2006
    #5
    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. Eric
    Replies:
    3
    Views:
    2,859
    OHM \( One Handed Man \)
    Apr 9, 2006
  2. Terry Jones
    Replies:
    3
    Views:
    792
    Nick Kew
    Mar 24, 2005
  3. Cronus
    Replies:
    1
    Views:
    667
    Paul Mensonides
    Jul 15, 2004
  4. =?ISO-8859-1?Q?Morris_Carr=E9?=

    Python passes the Turing test with a one-liner !

    =?ISO-8859-1?Q?Morris_Carr=E9?=, Apr 1, 2004, in forum: Python
    Replies:
    1
    Views:
    341
    Jon Perez
    Apr 2, 2004
  5. A. B., Khalid
    Replies:
    5
    Views:
    314
    A. B., Khalid
    Nov 22, 2004
Loading...

Share This Page