I can confirm that Yakov is correct; the // is allowed in C99, and not
in the older standard.

FYI, the C99 standard (ISO/IEC 9899-1999) is available on Amazon or
Bookpool, and probably other sites, for about $75 list.

http://www.amazon.com/gp/product/0470845732/ref=sr_11_1/102-4132906-9254519?%5Fencoding=UTF8
http://www.bookpool.com/sm/0470845732

I don't know if the older standard (ANSI X3.159-1989) is still available 
anywhere.
It's a shame really.  Everyone should have it right next to the K&R.

In the end though, IMHO, if you're writing C code you should use the
/**/ syntax.  If you have a choice, always code for maximum portability
and maintainability.

gm

On Tue, Jun 20, 2006 at 10:02:09AM -0600, Russell Bateman wrote:
> You know, I worked with this formally for years, but it's not impossible 
> that I missed something.
> 
> The last time I looked at the spec (and I no longer have access to one 
> because I've changed jobs and companies and the thing costs about $250), 
> it seemed to me that it was in the C++ part of the document.  I am 
> certain of the "strict ANSI compliance" thing because I demonstrated it 
> to myself  once when it was important to be strictly ANSI compliant in 
> something I was doing (unless things have changed with recent compiler 
> versions). Here, where I work now, we're strictly ANSI compliant and 
> that includes no C++ style comments, but truly, I haven't tested that 
> assertion since I'd get crucified if I did. Maybe I'll try it before 
> checking something in.
> 
> Russ
> 
> Yakov Lerner wrote:
> >On 6/20/06, Russell Bateman <[EMAIL PROTECTED]> wrote:
> >>Formally speaking, C99 (ISO/IEC 9899:1999) still refers to "ANSI C"
> >>which does not tolerate the C++ style comment operator.
> >
> >In the draft standard c99 (*1), 6.4.9.2, page 66, // is
> >defined as a comment.
> >
> >Is this something that was changed/removed
> >from the final standard ?
> >
> >Yakov
> >
> >(*1) http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf
> >
> >>Yakov Lerner wrote:
> >>> Some C sources that I have are c99, other are c89.
> >>>
> >>> The c99 sources can use //-style comments.
> >>> The c89 sources can use only /**/-style comments.
> >>>
> >>> I'd like to have my "commentify" macro to
> >>> use // in c99 sources, and /**/ in c89 sources.
> >>>
> >>> But how to tell those two types apart ? Any ideas ?
> >>> I'm thinking about searching the file for pre-existing //.
> >>> That's crude but I can't think of anything else.
> >>> What would be good method to detect c99 vs c89 ?
> >>>
> >>> Yakov
> >>>
> >>>
> >>
> >>
> >
> >

-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Gregory H. Margo
gmargo at yahoo/com, gmail/com, pacbell/net; greg at margofamily/org

Reply via email to