declarations in include files: how do YOU feel?
Robert W Berry
rwberry at hubcap.clemson.edu
Thu May 11 17:12:11 AEST 1989
>From article <11318 at bloom-beacon.MIT.EDU>, by scs at sloth.pika.mit.edu (Steve Summit):
> In article <179 at larry.sal.wisc.edu> jwp at larry.sal.wisc.edu (Jeffrey W Percival) writes:
... include variable declarations in header file? ...
>
> By all means. I'd say that this is the recommended standard
> practice. If you're using ANSI-style function prototypes, put
> the prototypes in too, of course. If you're not using
> prototypes, you may leave out extern declarations for those
> functions returning int. (You may also leave them in, for
> documentation purposes.)
Is it? I thought the more general practice was to define the
variable types (structures, unions, etc.) and have the programmer
declare a variable of the appropriate type for use in his function.
Look at file pointers (of type FILE *) that you declare for stream I/O,
low-level structures (such as REGS in Turbo C), windowing libraries
often have a structure called "window" that is manipulated by the
library rountines.
I definitely vote yes on having prototypes in the header file (if
you're into prototypes that is). But declaring variables there scares
me a little. (And there's always the nasty possibity of duplicating a
variable name -- although this already happens with certain structure
names in header files.)
Bob
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-=- Bob Berry -=- PC-Guru's Inc. ! rwberry at hubcap.clemson.edu -=-
-=- We are the science of modern motion. ! 803-654-7623 || 803-656-2635 -=-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
More information about the Comp.lang.c
mailing list