liveBook · Manning

Integer constant expression

An integer constant expression is an expression whose value can be determined during translation using only permitted constant operands and operations.

How 2 Manning books explain it

Modern C, Third Edition

An integer constant expression is a C expression whose value can be determined during translation using only permitted constant operands and operations.

How it is used
Supplies fixed case values, enumeration initializers, and a named array bound.
How deep it goes
Defines compile-time and object-evaluation restrictions through valid and invalid examples, without providing a complete grammar of permitted expressions.
Examples
Contrasts literal case labels with a variable and tests enumeration initializers built from literals, enum constants, const objects, and constexpr objects.
What you can do after
Evaluate/understand whether a proposed case value or enumeration initializer meets the illustrated ICE restrictions.

Read how Modern C, Third Edition explains integer constant expression →

Modern C

An integer constant expression is a C expression whose value is an integer constant determined according to the language's constant-expression rules.

How it is used
Constrains case labels and names compile-time integer values for enumerations.
How deep it goes
Defines compile-time evaluation and object exclusion, while deferring _Alignof, offsetof, and sizeof details.
Examples
Uses switch case labels, enumeration declarations, indexed arrays, and valid-versus-invalid enumeration initializers.
What you can do after
Apply it in C by distinguishing compile-time integer expressions from expressions that evaluate objects.

Read how Modern C explains integer constant expression →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.