global data in C programming...

Brad Banko btb at ncoast.UUCP
Mon Mar 14 11:47:42 AEST 1988


how does one use global data in C programming?
i thought that you just create a header file containing the global data
declarations and then #include it into each of your source files, but
when i try this (using Mark Williams C on an Atari ST), I get
a "symbol redefined" message from the linker.

basically, the type of thing that I am trying to do is:

x.h:
	int i,j;

x.c:
#include "x.h"

xyz() {
	i = ...
}

y.c:
#include "x.h"

zzt() {
	i = j ...
}


K&R doesn't help me out... the stuff about externs and header files is
sort of minimal.

Thanks.


-- 
			Brad Banko
			Columbus, Ohio
			(formerly ...!decvax!cwruecmp!ncoast!btb)
			btb%ncoast at mandrill.cwru.edu

"The only thing we have to fear on this planet is man."
			-- Carl Jung, 1875-1961



More information about the Comp.lang.c mailing list