typedef char* problem

Niels Basjes basjes@nlr.nl
Thu, 28 Aug 1997 11:44:31 +0200 (MET DST)


Hi,

I ran into the following problem with omniORB.
Assume this simple IDL file:

typedef string SomeValue; 

interface MyObject {
   boolean SetNewValue (in SomeValue new_value);  
}; 

Now I expected (after having worked with Orbix) to implement 
my C++ class as something like this:

#include "MyObject.hh"
class MyObject_i : public _sk_MyObject 
{
   public: 
      CORBA::Boolean SetNewValue(const SomeValue new_value);  
};

But when I do that I get a lot of errors.
It does work right when I change the above definition into:
CORBA::Boolean SetNewValue(const char * new_value);
This is because this is the function prototype as it is generated in to
the MyObject and _sk_MyObject superclasses.

The problem occurs because it turns out that in C++ when SomeValue
is defined as:
    typedef char* SomeValue;  // This is the generated code
These two lines do NOT mean the same thing !!!! 
    const SomeValue bla;
    const char* bla;
So the genereated definition for my function is not the same as what I
wrote ---> errors like "you can't instantiate an abstract class".

My current workaround is to do:
#include "MyObject.hh"
#define SomeValue char*
......

This works but is very nasty in terms of maintenance.

Can anyone tell me what I'm doing wrong, or is this a problem in omniORB.

Thanks in advance,

Niels Basjes

================================================================
| ir. Niels Basjes             | National Aerospace Laboratory |
| Phone      : +31-20-5113626  | Anthony Fokkerweg 2           |
| E-Mail@NLR : Basjes@NLR.nl   | 1059 CM Amsterdam             |
| E-Mail@Home: Niels@Basjes.nl | The Netherlands               |
================================================================