Mail Archives: djgpp/1998/08/16/03:07:32

Date: Sun, 16 Aug 1998 10:03:25 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Merlin <merlin__ AT geocities DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: A very basic question about C programming... diary of a newbie Part 1
In-Reply-To: <>
Message-ID: <Pine.SUN.3.91.980816095530.6981D-100000@is>
MIME-Version: 1.0

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 -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019