liveBook · Manning

Identifier

As explained in Modern C, Third Edition

An identifier is a programmer-defined name that denotes a program entity such as a variable, function, or parameter.

In `double A[5];`, `A` is an identifier: a name for a program entity. In `int main(void)`, `main` names a function. Identifiers also name type aliases, such as `size_t`, and constants, such as `EXIT_SUCCESS`. Unlike a literal such as `5`, an identifier refers to something whose properties must be established. section 2.1 section 2.2

Before using an identifier, give the compiler a declaration that says what it represents. Keywords are different: the language predefines them, and they must not be declared or redefined. TAKEAWAY: All identifiers in a program have to be declared. section 2.2

Read a declaration from the name outward

In `int argc;`, `argc` names an `int` object. In `double A[5];`, brackets mark `A` as an array of five `double` items. In `int main(int, char*[]);`, parentheses mark `main` as a function returning `int`. A declaration establishes these properties; a definition additionally specifies how and where an object or function comes to be. section 2.2 section 2.5

Names also affect readability. The standard-library type name `size_t` uses a trailing `_t` as a naming convention for types. Variable, function, and type names should make code accessible to its readers; a project's natural language and domain terminology can guide that choice. section 2.1 section 9.4

long année = 1990L; // Année de l'écriture de l'œuvre

`année` illustrates a non-Latin character in a C identifier, while the comment uses the same language for documentation. C23 clarifies allowed identifiers by referring to Unicode UAX #31; earlier standards permitted many such characters in principle, but their rules and tooling made use difficult. section 9.3

How Modern C, Third Edition covers it

How deep it goes
Defines identifier roles and works through declarations, then discusses Unicode portability without developing a full lexical grammar.
Examples
Uses `A`, `main`, `size_t`, and `EXIT_SUCCESS` for distinct roles, plus `année` for a non-Latin name.
What it assumes
Introduces identifier roles and declarations directly, while deferring detailed treatment of types and pointers.
What you can do after
Evaluate/understand what a declared C name denotes and choose readable names with awareness of Unicode portability.
How it connects
Connects identifiers to declarations, definitions, keywords, types, arrays, functions, and Unicode.

Also explained in

Compare how 5 books explain identifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.