Language Features
SC100 C Compiler
3-33
3.4.1.2.2 K&R/PCC mode syntax differences
The following are the syntax differences relative to the default standard mode:
The keywords
signed
,
const
, and
volatile
are disabled, so that they can be user identifiers. The
other non-K&R keywords (
enum
and
void
) are judged to have existed already in code and are not
disabled.
The
=
preceding an initializer may be omitted. A warning is issued. This was an anachronism even
in K&R.
0x
is accepted as a hexadecimal 0, with a warning.
1E+
is accepted as a floating point constant with an exponent of
0
, with a warning.
The compound assignment operators may be written as two tokens (for example, += may be
written + =).
The compound assignment operators may be written in their old-fashioned reversed forms (for
example, -= may be written =-). A warning is issued.
The digits 8 and 9 are allowed in octal constants. (For example, the constant 099 has the
value 9*8+9, or 81.)
The escape
\a
(alert) is not recognized in character and string constants.
3.4.1.2.3 K&R/PCC mode differences for declarations
The following are the declaration differences relative to the default ANSI mode:
Declarations of the form
typedef
some-type
void;
are ignored.
The names of functions and of external variables are always entered at the file scope.
A function declared
static
, which is used and never defined, is treated as if its storage class were
extern
(instead of causing an error for being undefined).
A file-scope array that has an unspecified storage class and remains incomplete at the end of the
compilation will be treated as if its storage class is
extern.
In ANSI mode, the number of elements
is changed to 1, and the storage class remains unspecified.
When a function parameter list begins with a
typedef
identifier, the parameter list is considered
prototyped only if the
typedef
identifier is followed by something other than a comma or right
parenthesis, as shown below in Example 3-16. Function parameters are allowed to have the same
names as
typedef
identifiers. In the normal ANSI mode, any parameter list that begins with a
typedef
identifier is considered prototyped, and Example 3-16 would produce an error.
Example 3-16. Prototyped parameter list
typedef int t;
int f(t) {}
int g(t x) {}
/* Old-style list */
/* Prototyped list, parameter x of type t */
The empty declaration
struct
x;
will not hide an outer-scope declaration of the same tag. It is
taken to refer to the outer declaration.