Search code examples
c++corbaidl

Corba IDL: default value for struct members


Is it possible to define a default value for struct members in CORBA IDL? Let's take the following struct as an example:

struct Example
{
    boolean test;
};

If I compile this IDL to C++, the variable 'test' will be uninitialized after object creation. I would like it to be always set to false until it is explicitly switched to true.


Solution

  • The OMG IDL to C++ mapping doesn't default initialize struct members. As you mentioned the IDL to C++11 mapping does specify a default value for all types, including all basic types. At the moment you have a compiler/OS supporting C++11 you should be able to use the IDL to C++11 mapping, it doesn't require you to use C++11 in your application code.