[omniORB] Dynamic stub doesn't compile under MSVC (struct inside union inside namespace)
Sai-Lai Lo
S.Lo@uk.research.att.com
23 Jan 2001 11:04:51 +0000
Lars,
There is a bug in the stub code. The idl compiler backend has treated
ParseTree as if it is a module.
The correct code should be:
#if defined(HAS_Cplusplus_Namespace) && defined(_MSC_VER)
// MSVC++ does not give the constant external linkage otherwise.
namespace test {
const CORBA::TypeCode_ptr ParseTree::_tc_Exp = _0RL_tc_test_mParseTree_mExp;
}
#else
I have not checked recently but the work around is really needed or else
you create a DLL out of this code and the symbol for the constant will be
missing.
Fix to the compiler will be checked-in to the CVS later.
Regards,
Sai-Lai
>>>>> Lars Immisch writes:
> Dear all,
> I have a problem with the code generated from the following idl file.
> The idl file is a stripped down version of my real definition, don't be
> surprised it's not very useful in itself.
> module test
> {
> enum TermType
> {
> terminal,
> expression
> };
> enum Operator
> {
> plus,
> minus
> };
> union ParseTree switch(TermType)
> {
> case terminal:
> long digit;
> case expression:
> struct Exp
> {
> Operator op;
> sequence<ParseTree> operands;
> } ex;
> };
> };
> When I compile the resulting DynSK.cpp file, I get an error on the second line
> of the following code snippet; MSVC complains that test_ParseTree does not
> exist or is not a namespace.
> namespace test_ParseTree = test::ParseTree;
> namespace test_ParseTree {
> const CORBA::TypeCode_ptr _tc_Exp = _0RL_tc_test_mParseTree_mExp;
> }
> These two lines seem to be a workaround specifically for MSVC, since the
> enclosing lines read:
> #if defined(HAS_Cplusplus_Namespace) && defined(_MSC_VER)
> // MSVC++ does not give the constant external linkage otherwise.
> namespace test_ParseTree = test::ParseTree;
> namespace test_ParseTree {
> const CORBA::TypeCode_ptr _tc_Exp = _0RL_tc_test_mParseTree_mExp;
> }
> #else
> const CORBA::TypeCode_ptr test::ParseTree::_tc_Exp = _0RL_tc_test_mParseTree_mExp;
> #endif
> The workaround is to remove the workaround in the DynSK.cpp file :-)
> Trying to understand why the workaround exists in the first place, I tried to
> reference CORBA::TypeCode_ptr test::ParseTree::_tc_Exp in another .cpp file
> after removing the workaround and that compiled and linked ok.
>> From the comment, I was assuming I would get a linker error.
> I have applied Service Pack 3 to my VC++ 6.0, maybe the behaviour is not
> consistent across versions?
> I'd appreciate any comments.
--
Sai-Lai Lo S.Lo@uk.research.att.com
AT&T Laboratories Cambridge WWW: http://www.uk.research.att.com
24a Trumpington Street Tel: +44 1223 343000
Cambridge CB2 1QA Fax: +44 1223 313542
ENGLAND