Compatibility with K&R C
5-15
TMS320C2x/C2xx/C5x C Language
-
ANSI interprets file scope definitions that have no initializers as
tentative
definitions
. In a single module, multiple definitions of this form are fused
together into a single definition. Under K&R, each definition is treated as
a separate definition, resulting in multiple definitions of the same object
(and usually an error). For example:
int a;
int a;
/* illegal if −pk used, OK if not */
Under ANSI, the result of these two declarations is a single definition for
the object a. For most K&R compilers, this sequence is illegal, because a
is defined twice.
-
ANSI prohibits, but K&R allows, objects with external linkage to be
redeclared as static:
extern int a;
static int a;
/* illegal unless −pk used */
-
Unrecognized escape sequences in string and character constants are
explicitly illegal under ANSI but ignored under K&R:
char c = ’\q’;
/* same as ’q’ if −pk, error if not */
-
ANSI specifies that bit fields must be of type integer or unsigned. With
−
pk, bit fields can be legally defined with any integral type. For example:
struct s
{
short f : 2;
/* illegal unless −pk used */
};
-
K&R syntax allows a trailing comma in enumerator lists:
enum { a, b, c, };
/* illegal unless −pk used */
-
K&R syntax allows trailing tokens on preprocessor directives:
#endif NAME
/* illegal unless −pk used */
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...