HP C Programmer's Guide (92434-90009)

142 Chapter5
Programming for Portability
Porting to ANSI Mode HP C
different structures, both named stname. The stname referred by the declaration was
created within prototype scope. This means it goes out of scope at the end of the
declaration of func3. The declaration of stname on the line following func3 is a new
instance of struct stname. When conflicting structures are detected, the compiler issues
an error:
types in call and definition of 'func3' have incompatible
struct/union pointer types for parameter 'arg'
This error can be fixed by switching the first two lines and thus declaring struct stname
prior to referencing it in the declaration of func3.
Mixing of const and volatile Qualifiers and Function Prototypes
Mixing the const and volatile qualifiers and prototypes can be tricky. Note that this
section uses the const qualifier for all of its examples; however, you could just as easily
substitute the volatile qualifier for const. The rules for prototype parameter passing are
the same as the rules for assignments. To illustrate this point, consider the following
declarations:
/* pointer to pointer to int */
int **actual0;
Figure 5-1.
/* const pointer to pointer to int */
int **const actual1;
Figure 5-2.
/* const pointer to const pointer to int */
int *const *const actual2;
Figure 5-3.
/* const pointer to const pointer to const int */
const int *const *const actual3;