Formally speaking, C99 (ISO/IEC 9899:1999) still refers to "ANSI C" which does not tolerate the C++ style comment operator. If you don't believe me, just pass whatever your compiler's "strict ANSI compliance" flag is and see if it doesn't croak on them. Back in 1989, ANSI had not yet conceded the standard to the international committee (ISO) and the C++ definition was just emerging, something that ISO would see to.

So, the double slashes aren't C at all, but C++. Nevertheless, I use them to write C code with personally except in very formal implementations.

Within the context of the C compiler, the distinction is an easily made one via preprocessor tests, but how Vim can make the determination is pretty threadbare as you point out. Obviously, you can make the Vim consumer dictate that in the .vimrc file, but for the guy working on both styles, that's a problem. Maybe the surest and safest approach is the file extension.

My best $.02.

Russ


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