#if #endif ?

Discussion in 'C++' started by boki, Sep 13, 2004.

  1. boki

    boki Guest

    Dear All,

    Could you please tell me what is a "#" stand for in c++?

    Why there is "#if 1" in program description?

    It go with "#endif"

    Could you please explain it? thank you very much.

    Best regards,
    Boki.
    boki, Sep 13, 2004
    #1
    1. Advertising

  2. boki

    Peter Kragh Guest

    boki wrote:
    > Dear All,
    >
    > Could you please tell me what is a "#" stand for in c++?
    >

    The "#" indicates a preprocessor directive. Your favorite C/C++ book
    will tell you more.

    BR,
    Peter
    Peter Kragh, Sep 13, 2004
    #2
    1. Advertising

  3. boki

    Jon Bell Guest

    In article <9ag1d.47114$>,
    Peter Kragh <> wrote:
    >boki wrote:
    >>
    >> Could you please tell me what is a "#" stand for in c++?

    >
    >The "#" indicates a preprocessor directive. Your favorite C/C++ book
    >will tell you more.


    Or a Google search:

    <http://www.google.com/search?q=C%2B%2B+%22preprocessor+directives%22>

    --
    Jon Bell <> Presbyterian College
    Dept. of Physics and Computer Science Clinton, South Carolina USA
    Jon Bell, Sep 13, 2004
    #3
  4. boki wrote:

    > Dear All,
    >
    > Could you please tell me what is a "#" stand for in c++?

    The '#' character is an indicator that a preprocessor
    keyword is coming up.


    > Why there is "#if 1" in program description?
    >
    > It go with "#endif"

    The #if..#endif sequence allows the preprocessor to
    remove blocks of source code before it is passed to
    the compiler. Thus it can behave as an easy way
    to "comment-out" blocks of code.

    Many programmers use:
    #if 0
    /* code not compiled */
    #endif
    To comment out the code. If the programmer wants
    the code to be compiled, the '0' is changed to
    a '1':
    #if 1
    /* code is now compiled */
    #endif

    >
    > Could you please explain it? thank you very much.
    >
    > Best regards,
    > Boki.

    Read up on preprocessor directives.


    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.comeaucomputing.com/learn/faq/
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    Thomas Matthews, Sep 13, 2004
    #4
  5. boki

    Old Wolf Guest

    Thomas Matthews <> wrote in message news:<lIg1d.1388$>...
    > boki wrote:
    >
    > > Dear All,
    > >
    > > Could you please tell me what is a "#" stand for in c++?

    > The '#' character is an indicator that a preprocessor
    > keyword is coming up.


    May be coming up: # by itself is a valid directive (which has
    no effect).
    Old Wolf, Sep 13, 2004
    #5
  6. boki

    boki Guest

    Thank you all very much.

    Best regards,
    Boki.

    Thomas Matthews <> wrote in message news:<lIg1d.1388$>...
    > boki wrote:
    >
    > > Dear All,
    > >
    > > Could you please tell me what is a "#" stand for in c++?

    > The '#' character is an indicator that a preprocessor
    > keyword is coming up.
    >
    >
    > > Why there is "#if 1" in program description?
    > >
    > > It go with "#endif"

    > The #if..#endif sequence allows the preprocessor to
    > remove blocks of source code before it is passed to
    > the compiler. Thus it can behave as an easy way
    > to "comment-out" blocks of code.
    >
    > Many programmers use:
    > #if 0
    > /* code not compiled */
    > #endif
    > To comment out the code. If the programmer wants
    > the code to be compiled, the '0' is changed to
    > a '1':
    > #if 1
    > /* code is now compiled */
    > #endif
    >
    > >
    > > Could you please explain it? thank you very much.
    > >
    > > Best regards,
    > > Boki.

    > Read up on preprocessor directives.
    >
    >
    > --
    > Thomas Matthews
    >
    > C++ newsgroup welcome message:
    > http://www.slack.net/~shiva/welcome.txt
    > C++ Faq: http://www.parashift.com/c -faq-lite
    > C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    > alt.comp.lang.learn.c-c++ faq:
    > http://www.comeaucomputing.com/learn/faq/
    > Other sites:
    > http://www.josuttis.com -- C++ STL Library book
    boki, Sep 14, 2004
    #6
  7. Thomas Matthews wrote:

    > boki wrote:
    >
    > > Dear All,
    > >
    > > Could you please tell me what is a "#" stand for in c++?

    > The '#' character is an indicator that a preprocessor
    > keyword is coming up.
    >
    > > Why there is "#if 1" in program description?
    > >
    > > It go with "#endif"

    > The #if..#endif sequence allows the preprocessor to
    > remove blocks of source code before it is passed to
    > the compiler. Thus it can behave as an easy way
    > to "comment-out" blocks of code.
    >
    > Many programmers use:
    > #if 0
    > /* code not compiled */
    > #endif
    > To comment out the code. If the programmer wants
    > the code to be compiled, the '0' is changed to
    > a '1':
    > #if 1
    > /* code is now compiled */
    > #endif


    the example you give is like a comment, however #if can also be used to
    selectively add different options into the code at compile time. For
    example:

    #if defined(DEBUG)
    #define MYERROR(x) printf("x")
    #else
    #define MYERROR(x)
    #endif

    which allows you to compile printf statements in your program for
    debugging then easily take them out when you are done debugging, simply
    by commenting out the line that defines DEBUG

    David
    David Lindauer, Sep 15, 2004
    #7
    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. =?Utf-8?B?TWFya04=?=

    <% if %> ... <% endif%>

    =?Utf-8?B?TWFya04=?=, Jun 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    578
    Random
    Jun 1, 2005
  2. prettysmurfed
    Replies:
    3
    Views:
    10,302
    MPBroida
    Oct 24, 2003
  3. Christopher M. Lusardi
    Replies:
    1
    Views:
    419
    Victor Bazarov
    Nov 19, 2004
  4. Christopher M. Lusardi
    Replies:
    1
    Views:
    342
    Victor Bazarov
    Nov 19, 2004
  5. mohan

    missing #endif problem

    mohan, Jan 16, 2006, in forum: C Programming
    Replies:
    1
    Views:
    979
    Vladimir S. Oka
    Jan 16, 2006
Loading...

Share This Page