[omniORB] Dynamic stub doesn't compile under MSVC (struct inside union inside namespace)

Lars Immisch lars@ibp.de
Mon, 22 Jan 2001 19:24:11 +0100


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.

Thanks,

Lars Immisch