An identifier is a sequence of characters that represents a
name for the following:
- Variable
- Function
- Label
- Type definition
- Structure, enumeration, or union tag
- Structure, enumeration, or union member
- Enumeration constant
- Macro
- Macro parameter
The following rules apply to identifiers:
- Identifiers consist of a sequence of one or more uppercase
or lowercase alphabetic characters, the digits 0 to 9, the dollar
sign ($), and the underscore character (_).
Using the $ character provokes a warning
from the compiler in strict ANSI mode.
- Character case is significant in identifiers; for
example, the identifier
Test1
is different from
the identifier test1
.
- Identifiers cannot begin with a digit.
- Do not begin identifiers with an underscore; the ANSI C
standard reserves these identifiers for internal names.
- Keywords are not identifiers (Section 1.4 lists the C keywords).
- Using the names of library functions for identifiers is
bad practice (Chapter 9 lists the
C library function names). A function with the same name as a
library function will supersede the library function. This may be
the desired outcome, but program maintenance can be confusing.
- In general, identifiers are separated by white space,
punctuators, or operators. For example, the following code
fragment has four identifiers:
struct employee { int number; char sex; } emp;
The identifiers are: employee
, number
, sex
, and emp
. (struct
, int
, and char
are keywords).
An identifier without external
linkage has at most 32,767 significant characters. An identifier
with external linkage has 1023 significant characters
on Digital UNIX systems and 31 significant characters for OpenVMS
platforms. (Section 2.8 describes linkage
in more detail.) Case is not significant in external identifiers on
OpenVMS systems.
Identifiers that differ within their significant characters
are different identifiers. If two or more identifiers differ
in nonsignificant characters only, they are treated as the same
identifier.
Previous Page | Next Page | Table of Contents | Index