C compiler for pdp-11 under RSX

Martin Minow minow at decvax.UUCP
Wed Jun 13 12:37:12 AEST 1984


Chris Torek (umcp-cs!chris) asks: "Is the following legal:

	extern int foo;
	...
	int foo;

or vice-versa."

Yes (both ways) in Decus C, which emits global references when
the file has been fully compiled.

I think this fails on Whitesmith's compilers (though I haven't checked).
However, the following should always work:

	extern int foo;
	...
	int foo = 0;	/* Explicit initialization */

Here is a more difficult problem:

	func() {
	    extern char *localfunc();
	    ...
	}

	static char *
	localfunc() {
	    ...
	}

The above will not work correctly per the draft Ansi standard as
the "globalness" of localfunc() was set by the *first* reference.
Thus, localfunc() is global to all functions.  The draft (and many
existing compilers) permit you to write:

	func() {
	    static char *localfunc();
	...

I believe that this is an error (i.e. that the local/global
distinction should be made by the defining instance), but the
standards committee seems to want to make things easier for the
people who want to write one-pass compilers.

Martin Minow
decvax!minow



More information about the Comp.lang.c mailing list