Mail Archives: djgpp/1998/08/16/03:07:32
On Thu, 13 Aug 1998, Merlin wrote:
> > void do_nothing(void);
>
> if you leave the void in brackets out it will be assumed..
No, it will tell the compiler that the argument listr is unspecified.
This will effectively disable the compiler's checks of the actual
parameters that the program will pass. The only piece of information
that the compiler will get is that the function's return value (or
rather, that there is none).
If you want to know *exactly* what does compiler think about a function
prototype, use the -aux-info switch to GCC, like this:
gcc -c file1.c file2.c ... -aux-info functions.X
You can submit any number of source files in this way; the functions'
prototypes will be written to the file that is the argument to -aux-info
switch (the .X extension is nothing more than a convention).
I have run GCC like this for your example, and here's what I got.
For a declaration like this:
void do_nothing ();
GCC says this:
/* compiled from: . */
/* declt.c:1:OC */ extern void do_nothing (/* ??? */);
And for the decalration like this:
void do_nothing (void);
GCC says this:
/* compiled from: . */
/* declt1.c:1:NC */ extern void do_nothing (void);
See the difference? In the first case GCC doesn't know anything about
the argument list. Also note the "NC" vs "OC" specifier: `O' here means
Old, i.e. GCC parses this as an old (aka: K&R) style declaration, which
doesn't say anything about arguments.
- Raw text -