Re: implicit void arguments not checked?

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

 



On Thu, Jul 13, 2006 at 08:48:23AM -0700, Ian Lance Taylor wrote:
> florin@xxxxxxxxx (Florin Iucha) writes:
> 
> > 1. Shouldn't gcc at least warn about greet being called with and argument
> > that is not present in the declaration?
> 
> 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?

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

> > 2. What -W option should I use to get the warning (if it is not by
> > default in Wall)?
> 
> -Wstrict-prototypes

   $ gcc -Wstrict-prototypes *.c
   greet.c:4: warning: function declaration isn’t a prototype
   In file included from hello.c:1:
   greet.h:4: warning: function declaration isn’t a prototype
   hello.c:4: warning: function declaration isn’t a prototype

It is complaining about everything ;(

florin

-- 
If we wish to count lines of code, we should not regard them as lines
produced but as lines spent.                       -- Edsger Dijkstra

Attachment: signature.asc
Description: Digital signature


[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