473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

are // comments legal at the ends of preprocessor lines?

.... making things like

#endif // of the "#ifdef DEBUG" part

valid? Or not?

- J.
Jul 19 '05 #1
3 2436
On Tue, 22 Jul 2003 19:25:21 +0200, "Jacek Dziedzic" <ja***********@janowo.net> wrote:
... making things like

#endif // of the "#ifdef DEBUG" part

valid? Or not?


Except for multi-line macro definitions the answer is yes.

The answer for multi-line macro definitions can possibly be that
the standard is somewhat less than clear about the effect.

You can probably find more information about the issue (which
I've nearly forgot, just a vague recollection that there is an
issue) by using a search engine, or delving into the standard.

Jul 19 '05 #2
"Alf P. Steinbach" <al***@start.no> wrote...
On Tue, 22 Jul 2003 19:25:21 +0200, "Jacek Dziedzic" <ja***********@janowo.net> wrote:
... making things like

#endif // of the "#ifdef DEBUG" part

valid? Or not?
Except for multi-line macro definitions the answer is yes.

The answer for multi-line macro definitions can possibly be that
the standard is somewhat less than clear about the effect.


How is it "less than clear"? See 2.1 Phases of translation.
'2' happens earlier than '3', and those happen earlier than '4'.
So, a backslash+newline in a // comment makes the comment span
more than one line. Then the comment is replaced with a single
space character, and only after that the preprocessing directives
are executed.

So, by the time preprocessor gets its hands on the directives,
there are no more comments in the file.
You can probably find more information about the issue (which
I've nearly forgot, just a vague recollection that there is an
issue) by using a search engine, or delving into the standard.


I didn't know there was an issue...

Victor
Jul 19 '05 #3
On Tue, 22 Jul 2003 13:59:32 -0400, "Victor Bazarov" <v.********@attAbi.com> wrote:
"Alf P. Steinbach" <al***@start.no> wrote...
On Tue, 22 Jul 2003 19:25:21 +0200, "Jacek Dziedzic"

<ja***********@janowo.net> wrote:
>... making things like
>
>#endif // of the "#ifdef DEBUG" part
>
>valid? Or not?


Except for multi-line macro definitions the answer is yes.

The answer for multi-line macro definitions can possibly be that
the standard is somewhat less than clear about the effect.


How is it "less than clear"? See 2.1 Phases of translation.
'2' happens earlier than '3', and those happen earlier than '4'.
So, a backslash+newline in a // comment makes the comment span
more than one line. Then the comment is replaced with a single
space character, and only after that the preprocessing directives
are executed.

So, by the time preprocessor gets its hands on the directives,
there are no more comments in the file.
You can probably find more information about the issue (which
I've nearly forgot, just a vague recollection that there is an
issue) by using a search engine, or delving into the standard.


I didn't know there was an issue...


Neither did I until it was discussed either here or in
comp.lang.c++.moderated, I'm not sure. Seeing your comments I
think the issue was about __LINE__. But not sure...

Cheers,

- Alf

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edward Diener | last post by:
Has there ever been any discussion of adding comments notation to Python, such as C++'s /* */, which could occur in the middle of a line or span multiple lines ? I would like to see it as a more...
2
by: TAM | last post by:
Hi, I have redesigned one html page by removing all the tables. You can see this test page at http://www.ngrain.com/css/home1.htm. Only home1.htm has been redesigned without tables. Rest of...
19
by: Alex Vinokur | last post by:
Is there any tool to count C-program lines except comments? Thanks, ===================================== Alex Vinokur mailto:alexvn@connect.to http://mathforum.org/library/view/10978.html...
10
by: Monk | last post by:
Hi, Have a query regarding comments that extend over multiple-lines. Would like to know if the standard's view of this, so that we can create a code which doesn't run into compiler specific...
40
by: Edward Elliott | last post by:
At the risk of flogging a dead horse, I'm wondering why Python doesn't have any multiline comments. One can abuse triple-quotes for that purpose, but that's obviously not what it's for and doesn't...
100
by: jacob navia | last post by:
Recently, a heated debate started because of poor mr heathfield was unable to compile a program with // comments. Here is a utility for him, so that he can (at last) compile my programs :-) ...
6
by: olivier.grant | last post by:
Hi All, I'm trying to define a macro that will allow me to write the following code : #include MY_MACRO( NAME, SPACE ) and end up with the following preprocessed code : #include NAME.hpp
3
by: MartinRinehart | last post by:
Tomorrow is block comment day. I want them to nest. I think the reason that they don't routinely nest is that it's a lot of trouble to code. Two questions: 1) Given a start and end location...
36
by: Max | last post by:
This was asked in a C test. Is the following code legal C? Is it legal in C90? C99? #define main() int main #define mainbody () { return 0; } mainbody
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.