Re: Re: Re: Optional args in C code.

Joe Knapka <[email protected]> 04 May 2004 17:04:18 -0600
Newsgroups gmane.comp.lang.prothon.devel
Message-ID <[email protected]>
"Mark Hahn" <[email protected]> writes:

> Joe Knapka wrote:
> 
> > If I tell GCC to conform to ISO C99 (which is "not fully supported" in
> > GCC 3.2, according to "man gcc"; so maybe this behavior is erroneous),
> > I get both C++ // comments and anywhere-decls. I can see no option to
> > Visual Studio .NET that makes it support C99 (I'm looking at the M$
> > Library docs for CL).
> 
> I have googled for "embedded declarations" and can only find them in
> reference to C++.  I can't find any mention of them in connection to C,
> either GNU or Microsoft.

A late committee draft of the ISO C99 standard is available at

<URL: http://std.dkuug.dk/jtc1/sc22/open/n2794/>

(C99 is the current recommended standard.)  Here's the BNF for blocks
(section 6.8.2); it clearly permits decls any old place.

"""
6.8.2  Compound statement, or block
Syntax

compound-statement:
        { block-item-list[opt] }
block-item-list:
        block-item
        block-item-list block-item
block-item:
        declaration
        statement

Semantics

A compound statement (also called a block) allows a set of
declarations and statements to be grouped into one syntactic unit. The
initializers of objects that have automatic storage duration, and the
variable length array declarators of ordinary identifiers with block
scope are evaluated and the values are stored in the objects
(including storing an indeterminate value in objects without an
initializer) each time that the declaration is reached in the order of
execution, as if it were a statement, and within each declaration in
the order that declarators appear.
"""

> Unless something new comes up, let stick with the "defacto ansii" which is
> the real ansii plus //, typedef, etc.  This defacto language seems to be a
> standard across the open-source world.
> 
> Of course the actual definition is whatever my Visual Studio supports and I
> have a feeling it will be frozen at whatever it is forever since Billy Gates
> cares not a whit about C anymore.

I think you can tell Visual studio to treat *.c files as if they were
C++, which would get you a large superset of the behavior you
want. Unfortunately, it would also allow others working on the
Win32/VS.NET platform to infect the code with C++-ism that the GCC
developers would then have to weed out.

I may be misinterpreting the .NET docs. You might try the /Ze
flag on a plain C file and see if that let you do the //
comments.

- Joe

-- 
Resist the feed.
--
If you really want to get my attention, send mail to
jknapka .at. kneuro .dot. net.