Thread: RE: [Dev-C++] Comment Delimiters
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-06-23 07:43:09
|
I accidentally erased Per Westermark's email so I reply without part of his message. Why use compilation under condition for comments in C++? The best approach on comments in C++ is to use always // for comments, and use /* */ only for debugging purposes (to comment out blocks of code). Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Daniel G. <sp...@ho...> - 2003-06-23 08:16:36
|
Agreed. #if 0 ..#endif is a great way of doing it.
>From: OROSZI Balázs <or...@vp...>
>To: dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 10:01:54 +0200
>
>André Macário Barros wrote:
>>Dear Users,
>>
>> Suppose you can´t use the /* and */ comment delimiters to put in comments
>>an area of a code in C++.
>> If I use the // command, must I put them in each line of this piece of
>>code?
>> Is there another way?
>
>There is a quick way:
>
>#if 0
>...
>#endif
>
>Because "0" is "false", #if 0 can be considered like if (false){...}, which
>will in fact, never execute. So all code, with or without comments, will
>not be parsed by the C preprocessor there.
>
>This approach is also better, because /* */ comments cannot be nested.
>
>--
>Greetings,
> Balázs
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
|
|
From: Damien . <g_...@ho...> - 2003-06-23 10:41:30
|
Guys, How exactly does '#if 0' ...#endif work? I assumed that the
preprocessor would skip the statements until it reached the #endif.
However, when I tried to compile the code(with gcc 3.2.2) below , i get a
"missing terminator character ' error" . It seems as though the code inside
of an #if 0...#endif statement must be C/C++ accurate. It is easy fixed
with a /*... */ .Care to elaborate....?
/* IfZero.c */
#include <stdio.h>
int main(void)
{
#if 0
This line should not be worried about. I'm quite sure it will *not* be
included.
#endif
printf("...");
return 0;
}
----Original Message Follows----
From: "Daniel Glenfield" <sp...@ho...>
To: or...@vp..., dev...@li...
Subject: Re: [Dev-C++] Comment Delimiters
Date: Mon, 23 Jun 2003 09:16:30 +0100
Agreed. #if 0 ..#endif is a great way of doing it.
>From: OROSZI Balázs <or...@vp...>
>To: dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 10:01:54 +0200
>
>André Macário Barros wrote:
>>Dear Users,
>>
>> Suppose you can´t use the /* and */ comment delimiters to put in comments
>>an area of a code in C++.
>> If I use the // command, must I put them in each line of this piece of
>>code?
>> Is there another way?
>
>There is a quick way:
>
>#if 0
>...
>#endif
>
>Because "0" is "false", #if 0 can be considered like if (false){...}, which
>will in fact, never execute. So all code, with or without comments, will
>not be parsed by the C preprocessor there.
>
>This approach is also better, because /* */ comments cannot be nested.
>
>--
>Greetings,
> Balázs
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
|
|
From: Per W. <pw...@ia...> - 2003-06-23 11:56:17
|
Normally you can put just about anything within the #ifdef/#endif or
#if/#endif block - except that you should be a bit carefull about lines
that ends with a \ or lines that start with #.
Even in a undefined block, the preprocessor will expect \ at the end of
the line to mean a line-continuation with, if the next source line
contains the #endif will spell trouble.
Since the compiler supports nested #ifdef constructs, any #ifdef, #if,
#else, #endif etc. might seriously affect the size of the deactivated
block.
/Per W
On Mon, 23 Jun 2003, Damien . wrote:
> Guys, How exactly does '#if 0' ...#endif work? I assumed that the
> preprocessor would skip the statements until it reached the #endif.
> However, when I tried to compile the code(with gcc 3.2.2) below , i get =
a
> "missing terminator character ' error" . It seems as though the code ins=
ide
> of an #if 0...#endif statement must be C/C++ accurate. It is easy fixed
> with a /*... */ .Care to elaborate....?
> /* IfZero.c */
> #include <stdio.h>
> int main(void)
> {
> #if 0
> This line should not be worried about. I'm quite sure it will *not* be
> included.
> #endif
> printf("...");
> return 0;
> }
>
> ----Original Message Follows----
> From: "Daniel Glenfield" <sp...@ho...>
> To: or...@vp..., dev...@li...
> Subject: Re: [Dev-C++] Comment Delimiters
> Date: Mon, 23 Jun 2003 09:16:30 +0100
>
> Agreed. #if 0 ..#endif is a great way of doing it.
>
>
> >From: OROSZI Bal=E1zs <or...@vp...>
> >To: dev...@li...
> >Subject: Re: [Dev-C++] Comment Delimiters
> >Date: Mon, 23 Jun 2003 10:01:54 +0200
> >
> >Andr=E9 Mac=E1rio Barros wrote:
> >>Dear Users,
> >>
> >>=09Suppose you can=B4t use the /* and */ comment delimiters to put in c=
omments
> >>an area of a code in C++.
> >>=09If I use the // command, must I put them in each line of this piece =
of
> >>code?
> >> Is there another way?
> >
> >There is a quick way:
> >
> >#if 0
> >...
> >#endif
> >
> >Because "0" is "false", #if 0 can be considered like if (false){...}, wh=
ich
> >will in fact, never execute. So all code, with or without comments, will
> >not be parsed by the C preprocessor there.
> >
> >This approach is also better, because /* */ comments cannot be nested.
> >
> >--
> >Greetings,
> > Bal=E1zs
> >
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by: INetU
> >Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmob=
ile
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*
> http://join.msn.com/?page=3Dfeatures/junkmail
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Daniel G. <sp...@ho...> - 2003-06-23 12:21:24
|
#if 0
cout << "This code will not be compiled, but I don't know if it needs to be
syntactically correct or not. Probably does" << endl;
#endif
Yes I know I've forgotten to #include the iostream header.
>From: "Damien ." <g_...@ho...>
>To: dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 06:41:24 -0400
>
>Guys, How exactly does '#if 0' ...#endif work? I assumed that the
>preprocessor would skip the statements until it reached the #endif.
>However, when I tried to compile the code(with gcc 3.2.2) below , i get a
>"missing terminator character ' error" . It seems as though the code
>inside of an #if 0...#endif statement must be C/C++ accurate. It is easy
>fixed with a /*... */ .Care to elaborate....?
>/* IfZero.c */
>#include <stdio.h>
>int main(void)
>{
>#if 0
>This line should not be worried about. I'm quite sure it will *not* be
>included.
>#endif
>printf("...");
>return 0;
>}
>
>----Original Message Follows----
>From: "Daniel Glenfield" <sp...@ho...>
>To: or...@vp..., dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 09:16:30 +0100
>
>Agreed. #if 0 ..#endif is a great way of doing it.
>
>
>>From: OROSZI Balázs <or...@vp...>
>>To: dev...@li...
>>Subject: Re: [Dev-C++] Comment Delimiters
>>Date: Mon, 23 Jun 2003 10:01:54 +0200
>>
>>André Macário Barros wrote:
>>>Dear Users,
>>>
>>> Suppose you can´t use the /* and */ comment delimiters to put in
>>>comments
>>>an area of a code in C++.
>>> If I use the // command, must I put them in each line of this piece of
>>>code?
>>> Is there another way?
>>
>>There is a quick way:
>>
>>#if 0
>>...
>>#endif
>>
>>Because "0" is "false", #if 0 can be considered like if (false){...},
>>which will in fact, never execute. So all code, with or without comments,
>>will not be parsed by the C preprocessor there.
>>
>>This approach is also better, because /* */ comments cannot be nested.
>>
>>--
>>Greetings,
>> Balázs
>>
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by: INetU
>>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>_________________________________________________________________
>On the move? Get Hotmail on your mobile phone
>http://www.msn.co.uk/msnmobile
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>_________________________________________________________________
>The new MSN 8: advanced junk mail protection and 2 months FREE*
>http://join.msn.com/?page=features/junkmail
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you.
http://www.msn.co.uk/internetaccess
|
|
From: Per W. <pw...@ia...> - 2003-06-23 08:55:06
|
Often the one asking a question don't really know exactly what they want - or at least doesn't specify it clearly enough. Yes, multiline comments should of course use /* ... */ but very often when someone gets bothered about commenting away a large number of lines, they are not thinking about a big block-comment, but a large block of unwanted code. /Per W On Mon, 23 Jun 2003, Ioannis Vranos wrote: > I accidentally erased Per Westermark's email so I reply without part of his > message. > > > Why use compilation under condition for comments in C++? > > The best approach on comments in C++ is to use always // for comments, and > use /* */ only for debugging purposes (to comment out blocks of code). > > > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ioannis V. <iv...@em...> - 2003-06-23 09:51:27
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] On Behalf=20 > Of Per Westermark > Sent: Monday, June 23, 2003 11:56 AM > To: Ioannis Vranos > Cc: 'Dev-Cpp-Users' > Subject: RE: [Dev-C++] Comment Delimiters >=20 >=20 > Often the one asking a question don't really know exactly=20 > what they want - > or at least doesn't specify it clearly enough. >=20 > Yes, multiline comments should of course use /* ... */ but=20 > very often when > someone gets bothered about commenting away a large number of=20 > lines, they > are not thinking about a big block-comment, but a large block=20 > of unwanted > code. I did not understand what you mean but a very good commenting style is = this: For comments use only //. Use /* */ only for debugging purposes. Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Per W. <pw...@ia...> - 2003-06-23 11:44:16
|
Yes, it is always good to have definned coding rules for new projects, but: 1 - /* */ doesn't support nesting except for some compilers. 2 - it is not uncommon for a project to inherrit code, and that code might use /* */ or might even be in C. The only two safe methods of deactivating a large block of code is to either delete the lines, or to #ifdef them. With good source control, the code delete is preferable since it's WYSIWYG. However, a lot of people doesn't use CVS or SourceSafe et. al at home, and then it is very easy to permanently loose deleted code lines. /Per W On Mon, 23 Jun 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: Per Westermark [mailto:pw...@ia...] On Behalf > > Of Per Westermark > > Sent: Monday, June 23, 2003 11:56 AM > > To: Ioannis Vranos > > Cc: 'Dev-Cpp-Users' > > Subject: RE: [Dev-C++] Comment Delimiters > > > > > > Often the one asking a question don't really know exactly > > what they want - > > or at least doesn't specify it clearly enough. > > > > Yes, multiline comments should of course use /* ... */ but > > very often when > > someone gets bothered about commenting away a large number of > > lines, they > > are not thinking about a big block-comment, but a large block > > of unwanted > > code. > > > I did not understand what you mean but a very good commenting style is this: > > > For comments use only //. > > Use /* */ only for debugging purposes. > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |