z/OS Language Environment Writing Interlanguage Communication Applications
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Calling packed structures and unions

z/OS Language Environment Writing Interlanguage Communication Applications
SA38-0684-00

Packed and unpacked objects can have different memory layouts. You can use ILC calls with arguments that are packed structures by using the #pragma pack(packed) support in C++.

Figure 1. Common header file (common.h)
#ifdef __cplusplus         /* if compiled with C++ compiler */
  #ifndef _Packed         /* define _Packed                 */
    #define _Packed
  #endif

  #pragma pack(packed)    /* 1-byte alignment is used     */
#endif

struct ss {
  int i;
  char j;
  int k;
};

typedef _Packed struct ss   packss;

#ifdef __cplusplus           /* if compiled with C++ compiler */
  #pragma pack(reset)        /* reset alignment rule          */
#endif

Figure 2. Common header file in C
#include "common.h"       /* include common header file */

void callcxx(packss);

main() {
  packss  packed;

  packed.i = 10;
  packed.j = 'a';
  packed.k = 33;

  callcxx(packed);
}
Figure 3. Common header file in C++This is a common header file in C++.

For more information about #pragma pack(packed) or on _Packed structures, see z/OS XL C++ Language Reference.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014