HPlogo HP C/HP-UX Programmer's Guide: Workstations and Servers > Chapter 6 Migrating C Programs to HP-UX

Invalid Structure References

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

The HP 9000 workstations and server compiler does not allow structure members to be referenced through a pointer to a different type of object. The VAX pcc and HP 9000 Series 200 and 500 compilers allow this. Change any invalid structure references to cast the pointer to the appropriate type before referencing the member. For example, given the following:

     struct x {
int y;
}z;
char *c;
c -> y=5;

c -> y=5; is invalid. Instead, use the following code:

     c = (char *) &z;
((struct x *) c)->y = 5;
© Hewlett-Packard Development Company, L.P.