function prototype vs function declaration



Dear C Experts,

While prepating a content for a C course,I made section on function
prototypes.
Could you kindly provide me your comments on its correctness. Thank you !

Q12: What is the difference between a function prototype and a function
declaration?

If you get this right, you must have done fair amount of research on C
programming beginning with "K&R" C. It turns out that function declarations
and function prototypes are the same thing in standard C. In K&R C a
function declaration did not need to have the types of its arguments to be
specified.

Thus a declaration like:



int Spi_Tx();



was perfectly acceptable, even though its definition was infact:



int Spi_Tx(uint8 TragetId,uint8 byteArray[],uint16 count)

{



}



It was easy for programmers to call the function with incorrect
parameters which needless to say had disastrous runtime consequences. Thus
ANSI C mandates function prototypes as the method for function declaration.



Regards,
Ravishankar


.



Relevant Pages

  • Re: passing a string to a C++ function
    ... it seemed to make perfect sense (before prototypes). ... Like so many things in the religion of programming there are lots of ways to ... > int f ...
    (microsoft.public.vc.language)
  • Re: Function prototypes
    ... A prototype is a function declaration that lists the ... are in fact using prototypes, ... As you should know by now, using proper terminology in the proper way is ... not a matter of word games, ...
    (comp.lang.c)
  • Re: Function prototypes
    ... A prototype is a function declaration that lists the ... For function definitions /not/ to do this, ... are in fact using prototypes, ...
    (comp.lang.c)
  • Re: Function prototypes
    ... A prototype is a function declaration that lists the ... For function definitions /not/ to do this, ... are in fact using prototypes, ...
    (comp.lang.c)
  • Re: function call with arguments which takes no arguments
    ... >> Even compiler doesn't show any warning. ... > C allows function declarations with empty parentheses for backwards ... > correct if he/she chooses NOT to use prototypes. ... There is no "int ...
    (comp.arch.embedded)