473,791 Members | 2,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2456
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+newli ne 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.********@att Abi.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+newli ne 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++.m oderated, 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
2341
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 elegant solution for quickly commenting out code. I am aware of the """ """ technique around multiple lines but even that seems a poor hack. A comment that could enclose any sequence of characters would be most welcome.
2
1646
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 the site uses tables for layout. I would appreciate if you can take a look at this page and CSS and comment on the coding.
19
5700
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 news://news.gmane.org/gmane.comp.lang.c++.perfometer =====================================
10
2093
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 issues. 1. A normal comments is /* comment text */ 2. A multiple line comment is
40
4645
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 nest properly. ML has a very elegant system for nested comments with (* and *). Using an editor to throw #s in front of every line has limitations. Your editor has to support it and you have to know how to use that feature. Not exactly...
100
5154
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 :-) More seriously, this code takes 560 bytes. Amazing isn't it? C is very ompact, you can do great things in a few bytes. Obviously I have avoided here, in consideration for his pedantic
6
3135
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
2762
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 (line position and char index) in an array of lines of text, how do you Pythonly extract the whole block comment? (Goal: not to have Bruno accusing me - correctly - of writing C in Python.) 2) My tokenizer has a bunch of module-level constants...
36
1961
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
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.