Public Comment Number PC-UK0262 ISO/IEC CD2 9899 (SC22N2794) Public Comment =========================================== Date: 1998-09-22 Author: N.M Maclaren Author Affiliation: Self Postal Address: University of Cambridge, Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB3 3QG, United Kingdom E-mail Address: Telephone Number: +44 1223 334761 Fax Number: +44 1223 334679 Category: Feature that should be included Committee Draft subsection: 6.3.1.3 and 6.10.6 Title: Detecting C89/C9X incompatibilities Detailed description: Because of the change in the status of the long and unsigned long types, it is very important to be able to detect when an application was conforming in C89 and is undefined in C9X, or has a different effect in C89 and C9X. The following should be added to 6.3.1.3: 6.3.1.3.1 The C89_MIGRATION pragma The C89_MIGRATION pragma can be used to constrain (if the state is on) or permit (if the state is off) integer conversions from higher ranks than long or unsigned long to types that are explicitly declared as either long or unsigned long. Each pragma can occur either outside external declarations or preceding all explicit declarations and statements inside a compound statement. When outside external declarations, the pragma takes effect from its occurrence until another C89_MIGRATION pragma is encountered, or until the end of the translation unit. When inside a compound statement, the pragma takes effect from its occurrence until another C89_MIGRATION pragma is encountered (within a nested compound statement), or until the end of the compound statement; at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement. If this pragma is used in any other context, the behavior is undefined. The default state (on or off) for the pragma is implementation-defined. For the purposes of the C89_MIGRATION pragma, a type is explicitly declared as long or unsigned long if its type category (6.2.5) is either long or unsigned long and either of the following conditions is true: The type specifier in the declaration or type name that defines the type is long or unsigned long, in any of the equivalent forms described in 6.7.2. The type specifier in the declaration or type name that defines the type is a typedef name which is not defined in a standard header and whose type satisfies the previous condition. This rule shall be applied recursively. Constraints If the state of the C89_MIGRATION pragma is on, no value with a signed integer type of higher integer conversion rank than long or with an unsigned integer type of higher integer conversion rank than unsigned long or shall be converted to a type that is explicitly declared as either type long or unsigned long. If the state of the C89_MIGRATION pragma is on, no function with a type that does not include a prototype shall be called with an argument that has a signed integer type of higher integer conversion rank than long or an unsigned integer type of higher integer conversion rank than unsigned long. Recommended practice A similar constraint should also be applied to programs that use conversion specifiers associated with long or unsigned long (e.g. %ld or %lu) for integer values or variables of a higher rank, where this can be checked during compilation. The following should be added to 6.10.6 #pragma STDC C89_MIGRATION on-off-switch