Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!rpi!uupsi!fozzie!stanley From: stanley@phoenix.com (John Stanley) Newsgroups: comp.lang.c Subject: Re: ANSI C prototypes Message-ID: Date: 30 Oct 90 18:32:46 GMT References: <1005@christopher-robin.cs.bham.ac.uk> Organization: One Man Brand Lines: 43 ptf@cs.bham.ac.uk (Paul Flinders ) writes: > Can anbody suggest an elegant solution to the following. > > in foo.h: > extern void ddprintf(const char *fmt, ...); > > BUT in foo.c: > > void ddprintf(va_alist) > va_dcl; > > this causes problems. The only solution that I've thought of is to > define some preprocessor token in foo.c _before_ the include of foo.h > and then #ifdef the extern declaration out. This seems a little messy > though. Anybody else have any solutions to this. There are two simple solutions: 1) Use a VAX. VMS C does not (at least, did not) care about the extern missing from extern declarations. This means the same include that defines a global int i may be included in all files. The linker on VMS happily ignores multiple definitions and layers everything with the same name to the same address. 2) Do what you thought of. It is pretty common, in my experience, that the main routine has a #define MAIN, with the included files having: #ifndef MAIN #define EXTERN #else #define EXTERN extern #endif This way, all global variables get defined in the main routine, and declared in the rest. You probably could just #define extern to nothing, but that would screw up any externs in any files follwing that one. "Arinth is a beautiful planet." "Oh, have you been there?" "Yes, but not yet." The Doctor. (TB)