3

We're using OmniORB with our C++ server. Currently, when an object is specified as a char in the IDL file, it is translated to an unsigned char in C++. We want it to be just char. Is there something we can change to make this happen?

Martin Ba
  • 33,741
  • 27
  • 150
  • 304
Jesse Jashinsky
  • 9,417
  • 6
  • 36
  • 61
  • Yeah, configure your compiler to treat char as unsigned by default (i.e. `-funsigned-char`). –  Feb 13 '14 at 20:59
  • 2
    "Can I change CORBA IDL to C++ Mapping" - a phrase uttered by thousands of C++ programmers in the late '90s. – Brian Kelly Feb 14 '14 at 02:35
  • I don't know the details of OmniORB, but TAO (see http://download.dre.vanderbilt.edu) does use the C++ char type for an IDL char. About changing the IDL mapping, have a look at the new IDL to C++11 language mapping, that realizes the mapping people have talked about for a long time (see http://www.omg.org/spec/CPP11/), we implement it as part of TAOX11 (see http://swsupport.remedy.nl). – Johnny Willemsen Feb 14 '14 at 11:01

2 Answers2

3

It is implementation defined (page 15 in the spec) what the IDL types boolean, char and octet map to.

omniORB chooses to:

...
typedef unsigned char _CORBA_Char;
typedef unsigned char _CORBA_Octet; 
...

You can change the omniORB sources, though I doubt that would be a good idea. Or you can accept that CORBA::Char does not represent the C++ char type.

Martin Ba
  • 33,741
  • 27
  • 150
  • 304
1

I would recommend using CORBA::Char when calling functions that are direct CORBA calls and assigning return values of such functions.

If you need to convert them to/from 'char' or 'unsigned char', a static_cast should do the job.

R Sahu
  • 196,807
  • 13
  • 136
  • 247