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
Uses integer constant expressions to specify enumeration constants and fixed switch case values.
How deep it goes
Defines compile-time and operand restrictions through examples without giving an exhaustive catalog of permitted operations.
Examples
Uses successive powers in an enumeration and contrasts const, constexpr, and enumeration constants in initializers.
What you can do after
Evaluate whether the illustrated enumeration initializers and switch case values meet the stated constant-expression requirements.

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 →

What to know first

Related concepts

Questions about integer constant expression

What is integer constant expression?

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

Which Manning books explain integer constant expression?

Modern C, Third Edition and Modern C.

What should I know before learning integer constant expression?

Manning books that teach integer constant expression usually introduce conditional logic, jump target and numerical algorithm first.

What is the difference between integer constant expression and compound literal?

An integer constant expression is an expression whose value can be determined during translation using only permitted constant operands and operations. A compound literal is a C expression consisting of a parenthesized type name followed by an initializer that creates an unnamed object.

What kinds of integer constant expression are there?

Kinds of integer constant expression include case value.

What is integer constant expression a kind of?

Integer constant expression is a kind of expression. An expression is a syntactically formed combination of values, names, operators, or other terms that denotes or evaluates to a value or result.

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.