Compatibility of pointers (C only)

Two pointer types with the same type qualifiers are compatible if they point to objects of compatible types. The composite type for two compatible pointer types is the similarly qualified pointer to the composite type.

The following example shows compatible declarations for the assignment operation:
      float subtotal;
      float * sub_ptr;
      /* ... */
      sub_ptr = &subtotal;
      printf("The subtotal is %f\n", *sub_ptr);
The next example shows incompatible declarations for the assignment operation:
      double league;
      int * minor;
      /* ... */
      minor = &league;     /* error */

Begin z/OS onlyPacked and nonpacked objects have different memory layouts. Consequently, a pointer to a packed structure or union is incompatible with a pointer to a corresponding nonpacked structure or union. As a result, comparisons and assignments between pointers to packed and nonpacked objects are not valid.

You can, however, perform these assignments and comparisons with type casts. In the following example, the cast operation lets you compare the two pointers, but you must be aware that ps1 still points to a nonpacked object:
int main(void)
{
   _Packed struct ss *ps1;
   struct ss         *ps2;
      …
   ps1 = (_Packed struct ss *)ps2;
      …}
End z/OS only