Undefined static function

g-chapma at gumby.UUCP g-chapma at gumby.UUCP
Sat Sep 21 05:05:50 AEST 1985


Regarding the "undefined static function" problem/question, viz:

	static char * f();

	main ()
	  {
	    ...
	    if (f(x)) ...
	    ...
	  }

	[end of file, no function definition for f]

Some compilers allow you to put the definition of statics (functions or
variables) in another file, as long as you combine the file containing 
the definitions with the file containing the references at some point 
before linkage time.

Whitesmiths' C compiler, for example, produces assembly code.  You must
compile each C source file separately (giving separate files of assembly 
code), but if you assemble the outputs together, the assembler will 
resolve the references.  The linker then sees no global symbol associated 
with the statics.

I took advantage of this feature to circumvent an inconvenient limit 
imposed by this compiler on the size of string constants.  I wrote a C 
source preprocessor which replaced specially-marked string constants with 
references to static string variables, and coded those constants in 
assembly code in a separate file.  I modified the compiler shell script
to run the preprocessor before the compiler, and assemble the string 
constant file along with the compiler output.

--Ralph Chapman
  g-chapma @ wisc-gumby @ uwvax



More information about the Comp.lang.c mailing list