Re: hunt_victim()

From: Herbert Kremser (kremser@flinux.tu-graz.ac.at)
Date: 08/17/95


On Thu, 17 Aug 1995, Ron Poulton wrote:

> > This is not true. Which linker do you use, who will complain about such
> > an error?
> > Usually the only instance which gives out a warning about wrong parameters
> > is the compiler, and the compiler can't do that without prototype.
> > Even if you use a wrong prototype in one file, neither the linker nor
> > the compiler will complain, therefore it's better in my experience,
> > to put prototypes in header files, and not in the .c files itself.
> 
> What if a .c file has no header?  Is it a matter of creating such a 
> header and including the prototypes in there?

Yes, i think that would be a good idea. After all thats one of the 
reasons why header files exist anyway.  :)

> something like 
> 'spec_procs.c' uses ACMD(do_say) quite often, and the file itself 
> contains a prototype for ACMD(do_say) in each function that uses it; I'm 
> not sure if creating a header file for a file would make the compiler 
> hurl or what.

Huh?

spec_procs.c has many header files, at least if you didn't remove them.  :)
In special true, ACMD(do_say) is only prototyped in the .c files where it's
needed, but that prototype is defined by a macro, and that macro is defined
in a header file.
By consequent use of that macro, and turning on a compiler warning, which
warns on implicit function declarations, most of the errors mentioned
above should be catched during compilation stage.

Quick browsing through Circle code, most "cross-file" functions are 
prototyped in header files anyway, or at least use a prototype-macro
which is in one of the header files.

Take for instance the function in modify.c.
If you are changing this for some reason from 
void string_add(struct descriptor_data *d, char *str) to 
void string_add(char *str, struct descriptor_data *d)
you have to update all of the calls to string_add.
However, if you forget to update one file, neither compiler nor linker
will complain.

So actually this isn't a bad thing, you only have to be sure what you
are doing. :)

Herbert

[on public request 12 lines of signature deleted]  *snip* ;)



This archive was generated by hypermail 2b30 : 12/18/00 PST