Many ANSI C questions (was: Nested(?) replacements, etc.)

Nick Crossley ndjc at capone.UUCP
Sat Oct 14 04:26:52 AEST 1989


In the referenced articles diamond at 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 at cbnewsl.ATT.COM> dfp at 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 at ccicpg.UUCP



More information about the Comp.std.c mailing list