Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!peregrine!ccicpg!taurus!capone!ndjc From: ndjc@capone.UUCP (Nick Crossley) Newsgroups: comp.std.c Subject: Re: Many ANSI C questions (was: Nested(?) replacements, etc.) Summary: Empty translation units should have been allowed Message-ID: <268@capone.UUCP> Date: 13 Oct 89 18:26:52 GMT References: <10885@riks.csl.sony.co.jp> <10889@riks.csl.sony.co.jp> <10891@riks.csl.sony.co.jp> <10892@riks.csl.sony.co.jp> <10893@riks.csl.sony.co.jp> <10959@riks.csl.sony.co.jp> <2259@cbnewsl.ATT.COM> Reply-To: ndjc@ccicpg.UUCP (Nick Crossley) Organization: CCI CPD, Irvine CA Lines: 36 In the referenced articles diamond@ws.sony.junet (Norman Diamond) writes: >The grammar given in the standard does not permit an empty source >file. Strangely enough, a preprocessor source file may be empty, >but since it cannot generate a non-empty real source file, error >detection is only delayed. In article <2259@cbnewsl.ATT.COM> dfp@cbnewsl.ATT.COM (david.f.prosser) replies: >A translation unit must contain at least one external declaration, >but can be made up of a number of source files, all but the original >via #include directives. Any of these #included files could be empty. But empty translation units are useful. I have several products where tracing code or machine/OS/version/... code is all put into separate source files; references to this code is controlled by appropriate macros and/or #ifs. These separate sources would look like: #if DEBUG function declarations #endif Now on an ANSI C compiler this will fail, or more likely give a warning (as it does on the AT&T V.4 system). I have to revise this apparently logical arrangement, or add dummy declarations, to remove these warnings. The same is true of a source file which contains only #ident (or #pragma ident) lines. I suppose there was a good reason for this decision, such as a known system incapable of handling emtpy translation units? -- <<< standard disclaimers >>> Nick Crossley, ICL NA, 9801 Muirlands, Irvine, CA 92718-2521, USA 714-458-7282 uunet!ccicpg!ndjc / ndjc@ccicpg.UUCP