Summary: Qualifiers

Keywords

Use the following keywords to qualify variables:

const, volatile, restrict

General Comments

A qualifier constrains a variable's use in some way. A const variable, after it's initialized, can't be altered. The compiler can't assume that a volatile variable hasn't been changed by some outside agency, such as a hardware update. A pointer qualified with restrict is understood to provide the only access (in a particular scope) to a block of memory.

Properties

Note

The declaration

const int joy = 101;

establishes that the value of joy is fixed at 101.

The declaration

volatile unsigned int incoming;

establishes that the value ...

Get C Primer Plus, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.