In message <
b5607488-bb02-416d-a511-1c2a90a28d0a@googlegroups.com>
news@sprow.co.uk wrote:
On Thursday, 26 March 2020 13:57:32 UTC, use...@garethlock.com wrote:
Been spending the time at home re-writing Brix in C.
The variables involved are declared as extern int32
Are they declared somewhere once (and only once) without extern?
If not - that's the problem.
The extern's tell the compiler that a variable exists elsewhere and
of what type, and the linker fixes up the references to it. But one
of the source files needs to have the variables without extern so
that the variable exists in memory,
That's not quite true - declaring a variable as extern, does, as you
say, simply tell the linker that the variable exists. But if you use:
extern int fred = 0;
then that is taken to be the defining point of fred and hence fred is
present in the compiled object file and the linker is happy.
The main point is that is that one of the source files needs to contain
a defining point for the variable, not that one of them shouldn't have "extern".
--
Nick Roberts tigger @ orpheusinternet.co.uk
Hanlon's Razor: Never attribute to malice that which
can be adequately explained by stupidity.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)