Previous Table of Contents Next


18.2.5 Mapping for Struct Types


   OMG IDL uses the keyword struct to define a record type, consisting of an ordered set of name-value pairs representing the member types and names. A structure defined in OMG IDL maps bidirectionally to Microsoft IDL and ODL structures. Each member of the structure is mapped according to the mapping rules for that data type.

   An OMG IDL struct type with members of types T0, T1, T2, and so on

   // OMG IDLtypedef ... T0typedef ... T1;typedef ... T2;...typedef ... Tn;struct STRUCTURE{

   T0 m0; T1 ml; T2 m2;

   ...Tn mN; };

   has an encoding equivalent to a Microsoft IDL and ODL structure definition, as follows.

   // Microsoft IDL and ODLtypedef ... T0;typedef ... Tl;typedef ... T2;

   ...

   typedef ... Tn;

   typedef struct

   {T0 m0; Tl ml;T2 m2; ... TN mN;

   } STRUCTURE;

   Self-referential data types are expanded in the same manner. For example,

   struct A { // OMG IDLsequence<A> v1;

   };

   is mapped as

   typedef struct A {struct { // MIDL

   unsigned long cbMaxSize;

   unsigned long cbLengthUsed;

   [size_is(cbMaxSize), length_is(cbLengthUsed), unique]

   struct A * pValue;

   } v1;} A;