c++ - Using extern to refer to a function defined in a different compilation unit -
due static data, have function
void foo(mynamespace::bar)
defined in compilation unit. point of use in compilation unit. use
namespace mynamespace { extern void foo(bar); }
but linker can't find function definition. misusing extern
?
extern
can used kind of thing.
your problem linker expecting function mynamespace::foo(bar);
due fact extern
statement within mynamespace
.
you have 2 choices:
use
extern void foo(mynamespace::bar);
@ "point of use". don't enclose line withinmynamespace
.alternatively, enclose function definition within
mynamespace
.
Comments
Post a Comment