c++ - Forward declaration of array of QStrings leads to segmentation fault -
c++ - Forward declaration of array of QStrings leads to segmentation fault -
in code have 2 forwards declarations, bool
array , qstring
array in namesace nlog
.
bool
works. qstring
produces segmentation fault.
header:
class log : public qobject { explicit log(); public: enum facility { third_party_fac, test_fac, __facility_last_element }; enum severity { debug_sev, warning_sev, critical_sev, fatal_sev, __severity_last_element }; }; namespace nlog { extern bool logging_enabled[log::__facility_last_element][log::__severity_last_element]; extern qstring severity_name[log::__severity_last_element]; }; class logstaticinitiallizer { public: logstaticinitiallizer(); }; static logstaticinitiallizer initiallizer=logstaticinitiallizer();
source:
qstring nlog::severity_name[log::__severity_last_element]; bool nlog::logging_enabled[log::__facility_last_element][log::__severity_last_element]; using nlog::logging_enabled; using nlog::severity_name; logstaticinitiallizer::logstaticinitiallizer() { qdebug()<<"0"; qdebug()<<logging_enabled[0][0]; qdebug()<<severity_name[0]; qdebug()<<"1"; }
it produces
0
false
and crashes @ qstring trace
as piotr s. said, problem logstaticinitiallizer
constructor called before initialization in source file.
also, there unrelated main problem reserved identifiers starting __
. see what rules using underscore in c++ identifier?
c++ arrays qt forward-declaration qstring
Comments
Post a Comment