Re: //Comments
Re: //Comments
- Subject: Re: //Comments
- From: Fritz Anderson <email@hidden>
- Date: Tue, 13 Jan 2009 13:00:28 -0600
On 13 Jan 2009, at 12:36 PM, Gil Dawson wrote:
I notice that some programs use // to begin comments. I tried them
using the C compiler that comes with XCode Version 2.5. They seem
to work in some places but not in others.
I didn't find the rules for this kind of comment in the K&R Second
Edition* that I have.
Where might I find the rules for this kind of comment? Could I
expect someone else's compiler to respect them?
//-comments have been recognized by C compilers, at least as an
extension, for at least 20 years. Because they'd historically been an
extension, I suppose the rules have varied subtly. This is what the
C99 standard (§6.4.9) says:
Except within a character constant, a string literal, or a comment,
the characters // introduce a comment that includes all multibyte
characters up to, but not including, the next new-line character.
The contents of such a comment are examined only to identify
multibyte characters and to find the terminating new-line character.
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf>
A compiler could be told to accept only an earlier version of C, with
no extensions. It would reject //-comments. I'd think that would be
rare in practice.
We'd have to see your specific code, and the error messages, to
explain why such comments don't always "work" for you. The reason that
occurs to me is that you've accidentally commented-out part of a
statement so as to ruin the syntax.
— F
--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >//Comments (From: Gil Dawson <email@hidden>) |