To answer Yakov's question though, and if he wants to abide by the rules
that he has provided he could do one of two things, so far as my limited
knowledge can tell:

1. Change the file extensions to represent the differences, for example
"foo.c89" and "foo.c99".

2. A nicer way would probably be to use modelines, namely put something
like this at the beginning of every file:

#if 0
        vim:ft=c89
#endif

Note my brilliant avoidance of // or /**/ style comments, just to make
sure :)

In both cases you would then need to do some mapping to tell vim that
c(89)9 should highlight and indent things just like c, something which I
am sure I could do with a bit of time that I do not currently have.

Can anyone tell me why anyone cares about the styles of comments? I
understand that it is important to adhere to standards, but I can't work
out why comments need to be in one of the two forms. Why not just use //
for inline comments and /**/ for function/block comments?

Or why not just use preprocessor commands to mask out your comments and
avoid all the confusion? (that was a joke, I think)

Max


> -----Original Message-----
> From: Russell Bateman [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 20, 2006 9:22 AM
> To: Yakov Lerner
> Cc: Vim List
> Subject: Re: how to detect c99 vs c89 (//-comments vs /*-comments)
> 
> Well, Yakov, I'm going to bow to you on this one because I don't have
a
> copy of the document to prove otherwise. Maybe the 2001 amendment put
//
> into C or maybe it didn't need to because it was already there. I know
> that as late as version 6 of CodeWarrior (2001), that compiler's
"strict
> ANSI compliance" switch did not tolerate C++ commenting.
> 
> The conclusion to draw is therefore that there is no way for Vim ever
to
> know.
> 
> Russ
> > Yakov Lerner wrote:
> >> On 6/20/06, Russell Bateman <[EMAIL PROTECTED]> wrote:
> >>> it seemed to me that it was in the C++ part of the document.
> >> c99 standard does not have any "C++ part"
> >>
> >>> 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
> >>
> >> Both c99 and c89 are ANSI C standards,  but they are different.
> >>
> >> Are you confusing "ANSI C" with "c89 ANSI C" ? If so, then
> >> "c89 ANSI standard" indeed does not have //. "c99 ANSI C standard"
> >> does have //. Additional references:
> >>
> >> (2) 'gcc -std=c99 -pedantic' accepts //-comments just fine.
> >> (3) This page refers to '//' as "c99 feature implemented in gcc':
> >>     http://gcc.gnu.org/gcc-3.4/c99status.html
> >>
> >> Yakov
> >>
> >>> 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
> >>> >> >
> >>> >> >
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>>
> >>>
> >>
> >>

Reply via email to