Common Usage C language level for the z/OS platform

The X/Open Portability Guide (XPG) Issue 3 describes a C language definition referred to as Common Usage C. This language definition is roughly equivalent to K&R C, and differs from the ISO C language definition. It is based on various C implementations that predate the ISO standard.

Common Usage C is supported with the LANGLVL(COMMONC) compiler option or the #pragma langlvl(commonc) directive. These cause the compiler to accept C source code containing Common Usage C constructs.

Many of the Common Usage C constructs are already supported by #pragma langlvl(extended). The following language elements are different from those accepted by pragma langlvl(extended).
  • Standard integral promotions preserve sign. For example, unsigned char or unsigned short are promoted to unsigned int. This is functionally equivalent to specifying the UPCONV compiler option.
  • Trigraphs are not processed in string or character literals. For example, consider the following source line:
    ??=define STR "??= not processed"
    The above line gets preprocessed to:
      #define STR "??= not processed"
  • The sizeof operator is permitted on bitfields. The result is the size of an unsigned int (4).
  • Bitfields other than type int are permitted. The compiler issues a warning and changes the type to unsigned int.
  • Macro parameters found within single or double quotation marks are expanded. For example, consider the following source lines:
       #define STR(AAA) "String is: AAA"
       #define ST STR(BBB)
    The above lines are preprocessed to:
       "String is: BBB"
  • Macros can be redefined without first being undefined (that is, without an intervening #undef). An informational message is issued saying that the second definition is used.
  • The empty comment (/**/) in a function-like macro is equivalent to the ISO token concatenation operator ##.

The LANGLVL compiler option is described in z/OS XL C/C++ User's Guide. The #pragma langlvl is described in #pragma langlvl (C only).