typedef char* problem

Sai-Lai Lo S.Lo@orl.co.uk
28 Aug 1997 12:29:40 +0100


Niels,

In the example you provided, the function signature generated by omniORB is
correct. It is *not a bug*. In fact, this is the *only case* in the C++
mapping for IN arguments where one cannot use the typedef name in the
stub's function signature. Let me explain:

The C++ mapping (table 24) specifies that an IN string argument is mapped to
const char*.

In C++, a const char* means that the object of type char points to by the
type is a constant. The pointer itself *is not a constant*.

On the otherhand, 'const SomeValue' means that the object SomeValue is a
constant. In your example, SomeValue is a pointer (char*). In otherwords,
'const SomeValue' makes the pointer itself a constant.

Therefore, using const SomeValue in the function signature is not a correct
mapping. One has to use the real type of SomeValue instead.

Besides, our version of Orbix (2.2 MT) generates the same mapping as
omniORB. 

In future, do let us know if you find any difference in the mapping
produced by omniORB and other ORB vendors. We have put in a lot of effort to
make sure that our mapping comply completely with the spec. The difference
may be caused by a bug in other ORBs, I hope so anyway :-)

Regards,

Sai-Lai


Niels Basjes <basjes@nlr.nl> writes:

> 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*
> ......
> 

-- 
E-mail:         S.Lo@orl.co.uk          |       Olivetti & Oracle Research Lab
                                        |       24a Trumpington Street
Tel:            +44 223 343000          |       Cambridge CB2 1QA
Fax:            +44 223 313542          |       ENGLAND