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:

  1. use extern void foo(mynamespace::bar); @ "point of use". don't enclose line within mynamespace.

  2. alternatively, enclose function definition within mynamespace.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -