K
Kyle Kolander
I was looking over the C++ standard for this answer and didn't find it...
probably not looking in the right spots.
Here's a quick setup:
// sn.h
extern const std::string SOME_NAME;
// sn.cpp
const std::string SOME_NAME = "SomeName";
/* sn.cpp is compiled and linked into libSomeName.so */
// myClass.h
#include <sn.h>
....
std::string ary[1] = { SOME_NAME };
// myClass.cpp
....
string s1 = ary[0]; // "" -- empty string
string s2 = SOME_NAME; // "SomeName"
Is this expected behavior? What is the order of initialization of global
variables (ary) vs. an extern string defined in a source file that has
already been compiled and linked into a library? I admittedly have not
spent enough time working with extern and generally shy away from global
variables...
Thanks,
Kyle
probably not looking in the right spots.
Here's a quick setup:
// sn.h
extern const std::string SOME_NAME;
// sn.cpp
const std::string SOME_NAME = "SomeName";
/* sn.cpp is compiled and linked into libSomeName.so */
// myClass.h
#include <sn.h>
....
std::string ary[1] = { SOME_NAME };
// myClass.cpp
....
string s1 = ary[0]; // "" -- empty string
string s2 = SOME_NAME; // "SomeName"
Is this expected behavior? What is the order of initialization of global
variables (ary) vs. an extern string defined in a source file that has
already been compiled and linked into a library? I admittedly have not
spent enough time working with extern and generally shy away from global
variables...
Thanks,
Kyle