Re: function prototype vs function declaration



Ravishankar S wrote:


"Richard Heathfield" <rjh@xxxxxxxxxxxxxxx> wrote in message
news:eNWdnUUdru5UPvranZ2dnUVZ8qXinZ2d@xxxxxxxxx
Ravishankar S said:

<snip>

It turns out that function
declarations and function prototypes are the same thing in standard
C.

No, it doesn't.

It is true that all function prototypes are function declarations,
but it is not true that all function declarations are function
prototypes.

<snip>

an example would help here.

int fx();

This is a function declaration, but not a prototype. In fact, argument
checking is turned of for functions declared like this. This is for
backwards compatibility and not recommended for new code. Use:

int fx(void);

or specify the parameters explicitly, as a prototype.

.



Relevant Pages

  • Re: Implicit int
    ... could not already do with long int, had they chosen so to do. ... amount of sense for such implementors - the pattern is a strong one. ... mixed declarations and code: in my view, these make code harder to read. ...
    (comp.std.c)
  • Re: Is this acceptable (i.e., compliant) code?
    ... I also only have them place those prototypes ... But he didn't say to put them in a header; ... topdown, I put *all* forward declarations before main, or the other ... > prototypes are an error source. ...
    (comp.lang.c)
  • Re: function prototype vs function declaration
    ... It is true that all function prototypes are function declarations, ... Recommends, but not mandates. ...
    (comp.lang.c)
  • Re: function prototype vs function declaration
    ... It is true that all function prototypes are function declarations, ... The C standard explicitly allows the use ...
    (comp.lang.c)
  • Re: function prototype vs function declaration
    ... It turns out that there is no difference between function declarations ... function prototypes as far as modern use of C is concerned. ... University of Colorado, Colorado Springs ... Text books do not trump the standard, and the standard explicitly allows functions declarations that are *not* prototypes. ...
    (comp.lang.c)