diff options
Diffstat (limited to 'cpp/src/slice2cppe/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cppe/Gen.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 02323403aba..a68f7e16936 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -303,7 +303,7 @@ Slice::Gen::generate(const UnitPtr& p) } Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _doneStaticSymbol(false) { } @@ -611,7 +611,16 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(!p->isLocal()) { - H << sp << nl << "static " << name << " __" << p->name() << "_init;"; + // + // We need an instance here to trigger initialization if the implementation is in a shared libarry. + // But we do this only once per source file, because a single instance is sufficient to initialize + // all of the globals in a shared library. + // + if(!_doneStaticSymbol) + { + _doneStaticSymbol = true; + H << sp << nl << "static " << name << " __" << p->name() << "_init;"; + } } } |