TLINK errors (cc/lint were clean)

Brent K. Barrett bkbarret at sactoh0.UUCP
Fri Feb 3 13:56:27 AEST 1989


In article <44100021 at hcx1>, ldh at hcx1.SSD.HARRIS.COM writes:
> 
> Here's one for the UNIX gurus who also know something about TurboC ...
> 
> Have a modularized program lint/cc do not object to the various modules ... TC2
> on the other hand does.
> 
 [ Chomp! ]j
> When invoked as follows, the TurboC 2.0 linker has a 2 major objections:
>     tlink \tc2\lib\c0m main module_a module_b,prog,prog,,\tc2\lib\cm
> 
> 
> 1) variables defined in header.h get linker error messages as follows:
> Error: _A defined in module MAIN.C is duplicated in module MODULE_A.C
> Error: _A defined in module MAIN.C is duplicated in module MODULE_B.C
> 
> 2) Certain basic stuff ends up being "undefined"
> Undefined symbol '_FOPEN' in module MAIN.C
> Undefined symbol '_PRINTF' in module MAIN.C
> 
> What is going on?!  This is the first time I have tried anything modularized on
> TC2 ... 
 
 Turbo C allows global variables to be declared only ONCE. Every
other time they are included in a module, they must be declared as
"extern"als.  Do the following to solve your problem:
 
 1) Place all your variable declarations into your main.c file as
is, then create a file called "extern.h" that lists the same
variable declarations prefixed by "extern."
  e.g.:
 
 float j;

    becomes:

 extern float j;
 
 2) simply #include "extern.h" in all your modules except main.c.

 I'm no Unix guru, but that will solve your TC problems.

-- 
 "Somebody help me! I'm trapped in this computer!"
  
 Brent Barrett ..pacbell!sactoh0!bkbarret GEMAIL: B.K.BARRETT



More information about the Comp.lang.c mailing list