Re: implicit void arguments not checked?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



florin@xxxxxxxxx (Florin Iucha) writes:

> > No.  In C, "void fn()" means that you are not saying anything about
> > the arguments accepted by the function.  As you mentioned, the way to
> > say that a function takes no arguments is "void fn(void)".
> 
> I knew that from K&R, but I was expecting ANSI C90 and C99 to tighten
> that up a bit. Otherwise, what would be the point of having function 
> declaration at all? Only for the return type?

C90 introduced function prototypes, but they had to be backward
compatible.  So they decided that fn() says nothing about argument
types.  Otherwise they would have broken all existing K&R C code.

> Do you have a hard reference (to the standard)?

C99 6.7.5.3 paragraph 14:

    An identifier list declares only the identifiers of the parameters
    of the function.  An empty list in a function declarator that is
    part of a definition of that function specifies that the function
    has no parameters.  The empty list in a function declarator that
    is not part of a definition of that function specifies that no
    information about the number or types of the parameters is
    supplied.(124)

Footnote 124:

    See ``future language directions'' (6.11.6).

6.11.6:

    The use of function declarators with empty parentheses (not
    prototype-format parameter type declarators) is an obsolescent
    feature.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux