This appendix discusses compatibility issues between IBM C and C++ Compilers and the XL C compiler.
IBM C and C++ Compilers is not fully compatible with XL C: it is a stricter compiler than XL C. The following are the differences:
Example 1: Mixing K&R-style and ANSI-style function prototypes.
void func(); void func(float f){ ..... }
Accepting this code leads to runtime problems since the float parameter in the definition is first promoted to double (default argument promotions). When the float argument is passed in, the wrong size registers are taken off the stack.
Example 2: Null dimension multi-dimensional arrays.
Arrays of incomplete arrays are not allowed, not even on parameters:
void f(int p[][]);
All dimensions except the first must be specified for a multi-dimensional array. In the above example, p is defined to be an incomplete array of an incomplete type (an incomplete array of an incomplete array of int).
Example 3: Tags introduced at parameter scope are not exported to the enclosing non-parameter scope.
int f(struct a *); struct a { int a; }; int f(struct a* i ) { return i->a; }
The type struct a was introduced in a parameter list, and will go out of scope at the end of the function declaration or definition.
#include <stdio.h> void func(int i, int j, int k) { printf("i = %d, j = %d, k = %d\n",i,j,k); } main() { int r=1; int c=0; func(c=r,r,r=4); }
With XL C 1.3 the results are:
i = 1 j = 1 k = 4
With IBM C and C++ Compilers the results are:
i = 1 j = 4 k = 4