### Declare Objects to be Shared between 16-bit and 32-bit Code (OS/2)

Because a 16-bit program cannot access a data item that is larger than 64K in size or that spans a 64K boundary in memory, any data items that are to be shared between 16-bit and 32-bit programs must conform to these limits.

Use the #pragma seg16 directive to ensure that shared data items do not cross 64K boundaries. In most cases, you need only use this #pragma with items that are likely to cross 64K boundaries, such as aggregates, doubles, and long doubles.

You can use #pragma seg16 either with the data item directly or through a typedef. The following code fragment shows both ways of using #pragma seg16:

        struct family {
         long          john;
         double        carolynn;
         char * _Seg16 geoff;
         long          colleen;
       };

       #pragma seg16( cat )
       struct family cat;           /* cat is qualified directly */

       typedef struct family tom;        (1)
       #pragma seg16( tom )              (2)

       tom  edna;        /* edna is qualified using a typedef */ (3)

Note: Using #pragma seg16 on variables of type struct family does not mean that pointers inside the structure will automatically be qualified with _Seg16. If you want the pointers to be qualified as such, you must declare them yourself.

The directive can be used either before or after the variable or typedef name is declared. In the case of the typedef, however, the #pragma must be attached to the typedef name before that name is used in another declaration. For example, in the preceding example, lines (1) and (2) can appear in any order, but both must appear before line (3).

The #pragma seg16 directive cannot be used on objects greater than 64K.

Call Between 32-bit and 16-bit Code

Declare Segmented Pointers