Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > #if #endif ?

Reply
Thread Tools

#if #endif ?

 
 
boki
Guest
Posts: n/a
 
      09-13-2004
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.
 
Reply With Quote
 
 
 
 
Peter Kragh
Guest
Posts: n/a
 
      09-13-2004
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
 
Reply With Quote
 
 
 
 
Jon Bell
Guest
Posts: n/a
 
      09-13-2004
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
 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      09-13-2004
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

 
Reply With Quote
 
Old Wolf
Guest
Posts: n/a
 
      09-13-2004
Thomas Matthews <> wrote in message news:<lIg1d.1388$ m>...
> 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).
 
Reply With Quote
 
boki
Guest
Posts: n/a
 
      09-14-2004
Thank you all very much.

Best regards,
Boki.

Thomas Matthews <> wrote in message news:<lIg1d.1388$ m>...
> 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

 
Reply With Quote
 
David Lindauer
Guest
Posts: n/a
 
      09-15-2004


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57