### Declare Segmented Pointers (OS/2)

Use the _Seg16 type qualifier to declare external pointers that will be shared between 32-bit and 16-bit code, that is, that are declared in both.

For example:

       char * _Seg16 p16;

directs the compiler to store the pointer as a segmented pointer (with a 16-bit selector and 16-bit offset) that can be used directly by a 16-bit application. The _Seg16 keyword comes after the asterisk in the declaration, as required by ANSI syntax rules.

When a _Seg16 pointer is used in 32-bit code, IBM C and C++ Compilers automatically converts it to a flat 32-bit pointer when necessary.

        char * _Seg16 p16;
       char * _Seg16 * _Seg16 pp16;
       char * p32;

       p32=p16;       (1)           /* Automatic conversion */
       *pp16=p32;     (2)           /*           Here, too  */
       p16++;         (3)    /* Two conversions happen here */

(1) `p16` is converted from seg to flat before being stored in `p32`.

(2) `pp16` is converted to flat before being dereferenced, `p32` is converted to `seg` before being stored in`*pp16`.

(3) `p16` is converted to flat, is incremented, and then converted back to `seg` before being stored back in `p16`.

Note:

> The _Seg16 keyword comes after the asterisk in the declaration, as required by ANSI syntax rules. Programmers familiar with other compilers may be accustomed to placing the far keyword in their declarations, but to the left of the asterisk:

>        char far * x;

> Because this syntax is contrary to ANSI binding rules, IBM C and C++ Compilers does not support it.

Call between 16-bit and 32-bit Code

Declare Objects to be Shared between 16-bit and 32-bit Code