[omniORB] "using namespace" can't disambiguate generated types
Tom O'Reilly
oreilly at mbari.org
Fri Jul 13 20:36:45 BST 2007
I have been really struggling on this one.
I've defined a module in my IDL interface, generated C++ code with omniIDL, and for some reason am unable to take advantage of the C++ "using namespace" directive - thus I need to specify the actual namespace *everywhere* in my application code. Why the heck doesn't "using namespace" help disambiguate types in the generated classes?
Here is my simple IDL interface:
module oreillyTest {
interface ServerTest {
enum Status {
Ok, Failed
};
void ping();
short foo(out float x);
};
};
I compile the IDL to C++ with the following:
omniidl -bcxx -Wbh=.h -Wbs=_SK.cc ServerTest.idl
Now here is a simple implementation of the IDL interface:
#include "ServerTest.h"
class BasicServer : virtual public POA_test::ServerTest {
public:
BasicServer(oreillyTest::ServerTest::Status status);
virtual void ping();
oreillyTest::ServerTest::Status _status;
};
using namespace oreillyTest; // Don't want to use namespace everywhere
BasicServer::BasicServer(ServerTest::Status status) { // COMPILER ERROR HERE!!!
_status = status;
}
For some reason, gcc (v 4.0.0) cannot successfully compile this, giving:
BasicServer.cc:5: error: expected `)' before 'status'
I.e. I must prepend the namespace "oreillyTest::" before every occurrence of ServerTest::Status - even though I've specified "using namespace oreillyTest" - does anyone know why?
Thanks,
Tom
--------------------------------------------------
Thomas C. O'Reilly
Monterey Bay Aquarium Research Institute
7700 Sandholdt Road
Moss Landing, California 95039-9644
831-775-1766 (voice)
831-775-1620 (FAX)
oreilly at mbari.org (email)
http://www.mbari.org (World-wide Web)
"The machine does not isolate man from the great mysteries
of nature, but plunges him more deeply into them."
- ANTOINE DE SAINT-EXUPERY
"Wind, Sand, and Stars" (1939)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20070713/6e744b36/attachment.htm
More information about the omniORB-list
mailing list