Name usage in client programs

Within a C or C++ program, the global name for a type, constant, or exception corresponding to an IDL scoped name is derived by converting the string "::" to an underscore ("_") and removing the leading underscore. Such names are referred to as C-scoped names. This means that types, constants, and exceptions defined within the interface statement for a class can be referenced in a C/C++ program by prepending the class name to the name of the type, constant, or exception. For example, consider the types defined in the following IDL specification:

   typedef sequence<long,10> mySeq;
   interface myClass : SOMObject
   {
      enum color {red, white, blue};
      typedef string<100> longString;
      ...
   }

These types could be accessed within a C or C++ program with the following global names:

mySeq,
myClass_color,
myClass_red,
myClass_white,
myClass_blue, and
myClass_longString.

Type, constant, and exception names defined within modules similarly have the module name prepended. When using SOM's C/C++ bindings, the short form of type, constant, and exception names (such as, color, longString) can also be used where unambiguous, except that enumeration names must be referred to using the long form (for example, myClass_red and not simply red).

Because replacing "::" with an underscore to create global names can lead to ambiguity if an IDL identifier contains underscores, it is best to avoid the use of underscores when defining IDL identifiers.


[Back: Scooping and name resolution]
[Next: Extensions to CORBA IDL permitted by SOM IDL]