From 154d294f53e38f1efc716f579b05ace811b6fe3a Mon Sep 17 00:00:00 2001 From: Michi Henning Date: Wed, 20 Jul 2005 00:59:46 +0000 Subject: Fixed bug 369. --- cpp/src/slice2cppe/Gen.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'cpp/src/slice2cppe/Gen.cpp') 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;"; + } } } -- cgit v1.2.3