IBM C and C++ Compilers and XL C Compatibility

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:

  1. IBM C and C++ Compilers implements tighter ANSI conformance. For example, the following code segments are accepted by XL C, but not by IBM C and C++ Compilers:

    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.

  2. IBM C and C++ Compilers may differ from XL C in implementation-defined parts of the language.
  3. IBM C and C++ Compilers differs from XL C where provisions for future extensions are implemented.