View Single Post
  #6   Spotlight this post!  
Unread 21-01-2006, 18:53
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: "call of function without prototype"

Quote:
Originally Posted by Andrew Blair
Not to get too far off topic, but what is the purpose of a prototype in a header file? Why not just directly call it from a .c file?
In our code it doesn't matter to much, but in normal C/C++ you will often have your code divded up into modules. Each module might define say 10 functions. When you prototype something, the compiler can use it, even if it doesn't have the code to do it at that point. It just assumes that it will find the code for the function later on.

So if fileA.h has a prototype to "addThese(int,int,int)", and fileB and fileC both need to use it, they just have to include the header, rather then having three copies of the code for the function.