Subject: Re: xosview and machine/cpu.h problems
To: Brian C. Grayson <bgrayson@ece.utexas.edu>
From: Erik Bertelsen <erik@sockdev.uni-c.dk>
List: port-mac68k
Date: 12/31/1997 13:08:45
On Tue, 30 Dec 1997, Brian C. Grayson wrote:

.. c++  -L./netbsd -L/usr/X11R6/lib -o xosview llist.o  Host.o 
..       xwin.o  Xrm.o  defaultstring.o  meter.o  fieldmeter.o 
..       fieldmeterdecay.o  bitmeter.o  xosview.o  main.o -lmeter -lX11 -lkvm
.. ./netbsd/libmeter.a(memmeter.o): Definition of symbol `_astpending' (multiply defined)
.. ./netbsd/libmeter.a(memmeter.o): Definition of symbol `_want_resched' (multiply defined)
.. ./netbsd/libmeter.a(pagemeter.o): Definition of symbol `_astpending' (multiply defined)
.. ./netbsd/libmeter.a(pagemeter.o): Definition of symbol `_want_resched' (multiply defined)
.. *** Error code 1   
.. 
.. > > It's my understanding that such a reference in a file just adds a
.. > > reference to the variable, and saying something like astpending=1; in
.. > > the body of the code would actually allocate the storage. So I
.. > > think the messages should be "<symbol> referenced from text" or 
.. > > something like that.
.. 

In general, you should place extern declarations of a variable whenever
you need to reference it, either in .c files or in .h files (then probably
just one .h file), and then you place a definition in exactly one of
your .c files with or without an initializer (this is typically done
in the .c file that "owns" the variable).

Doing it this way will work with either ISO or K&R C, while the method
of defining a variable in several places (like Fortran commons) only
works with K&R C.


- Erik