Mail Archives: djgpp/1998/08/14/00:45:35
Hans-Bernhard Broeker wrote:
> In article <35D2A017 DOT 4808178C AT geocities DOT com> you wrote:
>
> > Eli Zaretskii wrote:
>
> > > On Wed, 12 Aug 1998, Merlin wrote:
> > >
> > > > void do_nothing(); //these are prototypes
> > >
> > > No, this isn't a prototype. This is:
> > >
> > > void do_nothing(void);
>
> > if you leave the void in brackets out it will be assumed..
>
> Wrong. In C, leaving out the argument list completely means you just
> wrote an 'old-style' (i.e.: K&R) function declaration, not a
> prototype. In detail, it does *not* define the function to take no
> arguments at all, it simply doesn't tell anything about the arguments.
> That means:
>
> void do_nothing();
>
> int main(void) {
> do_nothing(235);
> return 0;
> }
>
> void do_nothing(foo)
> int foo;
> {
> foo = foo + foo;
> }
>
> is a valid, correct ANSI-C program. It compiles, links and even works
> without any problem or warning message with 'gcc -ansi -pedantic -Wall
> -W -g -O'. Change the first line to 'void do_nothing(void);', and gcc
> won't even compile it any longer.
>
sorry..my mistake...
> C++ is a different case: there '()' means '(void)', which itself is
> *illegal*. At least, that's what my lossy memory tells me.
but in c++ if '()' means '(void)' then wouldn't '()' = '(void)' and
therfore the prototype be right?..
l8r,
Merlin.
- Raw text -