473,836 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comments format: comments extending over multi-line

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
/* comment text <new line>
more comment text <new line>
.... <many new lines>
comment text */

1 is fairly common. Does the standard say anything about format 2 ? I
suspect different compilers might interpret 2 differently so the
question.

Any opinions or views on this issue are also welcome.

Sachin

Nov 14 '05
10 2106

In article <ln************ @nuthaus.mib.or g>, Keith Thompson <ks***@mib.or g> writes:
Jason Curl <j_********@mot orola.com> writes:

Some compilers will see a nested comment and see that line 3 contains
the end of the comment, other compilers will see line 2 ending the
comment and fail compilation on line 3.


No, nested comments are not part of the standard. Since some code
actually depends on a "/*" within a comment being ignored, a compiler
that allowed nested comments (at least in its default mode) would
cause problems.


For example, I've worked with at least one programmer who liked to put
a comment at the end of nearly every line, and liked to comment out
code by inserting "/*" at the beginning of the line, thus:

foo(x); /* do something */
/* bar(x); /* do something else */
/* baz(x); /* and yet another thing */
return x;

A compiler that "allowed nested comments" (ie, failed to process
comments as mandated by the C language) would fail to compile this
correctly.

Now, this is a poor practice, for a number of reasons; for example,
if this programmer had put /* at the beginning of the final line
above, the comment would have extended until a */ was found further
down in the source file. It's much better to use #if / #endif to
suppress interpretation of a section of code. However, there is C
code which uses it, and so "supporting " nested comments would be a
Bad Thing.

--
Michael Wojcik mi************@ microfocus.com

Then a good friend got very ill, and it made Pernsteiner realize that
"life is short. This was an opportunity to be silly."
Nov 14 '05 #11

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

Similar topics

13
2068
by: Ian Hickson | last post by:
A group of us have been unofficially working on a proposal of extensions to HTML4's Forms chapter, and would like to get input from a wider range of people now that we think our draft proposal is reaching a stable stage: http://www.whatwg.org/specs/web-forms/2004-06-27-call-for-comments/ Some of the features we are proposing include new input control types for dates, times, e-mail addresses, and numbers; a new client-side validation...
1
1741
by: Jonnie | last post by:
I am in the process of building an employee database for use by the management team here. They current have Access 97 (I am working on getting them to upgrade to at least 2000). For the most part I have it under control. There are several points that have popped up as wanted features and I need to verify somethings. 1. We now want to add the ability to add comments/notes with time and date stamps to an employees record. These comments...
0
2345
by: Klaus Bonadt | last post by:
I would like to parse an email, which I receive from a pop3 account. While the subject and the sender's email address are probably easy to determine, the body seems to be more difficult because of multi-part messages in MIME format. I am interested only in the plain text. Do you know an easy way to retrieve plain text of the body from an email message? Maybe a class, which can be constructed using the whole message string as a parameter...
2
1202
by: Vivek Kumar | last post by:
Hi all, I have to write a network server (sort of) and I am looking for your valuable comments. Currently I have written a prototype in VB6 but it can only handle up to 30 or so clients. I need to upgrade the application so that it can handle up to 1000-1500 clients at a time (later if every thing works fine then hoping for 5000-6000 client). The scenario is as follows.
5
3836
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where confusion veered it's ugly head :( Learning Python explains on page 324: Class Interface Techniques (21.3.3 in the ebook) the following is an extender method. ''' #################################### '''
11
10581
by: shsandeep | last post by:
I used the following query to retrieve the date in dd-mon-yyyy format. db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' || RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' || RTRIM(CHAR(YEAR(COVG_TYP_STRT_DT))) FROM twd_coverage_type 1 ---------------------------------------------------------------------------------------------------------------------------- 6-May-2006 1 record(s) selected.
0
2325
by: MAILER-DAEMON | last post by:
This is a multi-part message in MIME format. --FLMNOQRSTUVXYZabcefghjklmnoqrstuvxyz0124 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message has been processed by Symantec AntiVirus. instruction.exe was infected with the malicious virus W32.Mydoom!gen and has been deleted because the file cannot be cleaned. --FLMNOQRSTUVXYZabcefghjklmnoqrstuvxyz0124
0
1569
by: vishnu | last post by:
Hello All, I have embedded python 2.5 in to my C application. As we need the python scripts to run in multi threaded environment I have used Py_NewInterpreter() and Py_EndInterpreter each time I execute a run script function. The code is as follows: RunScript(char *pScriptName,char *pFuncName,...) { PyEval_AcquireLock()
3
3679
by: katis | last post by:
Hi all :) Is it posible in xsd to change only minOccurs value of element in complex type by extending this type? The problem I'm trying to solve is this: I have two complex types - "TextField" and "FileChooser". Here is definition of "TextField" <xsd:complexType name="TextField">
1
1714
by: =?iso-8859-1?q?Fran=E7ois_Beretti?= | last post by:
Hi, I want to design an XML format for my application. Documents using this format will describe LDAP classes and attributes. I have found the DSML format ( http://xml.coverpages.org/dsmlv1.html ) which does a part of what I want. But I want to add some information to it. For example, with DSML I can write :
0
9656
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
10821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10571
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10241
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
6973
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
5642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4001
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3102
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.