ANSI C Type Qualifiers

You've seen that a variable is characterized by both its type and its storage class. C90 added two more properties: constancy and volatility. These properties are declared with the keywords const and volatile, which create qualified types. The C99 standard adds a third qualifier, restrict, designed to facilitate compiler optimizations.

C99 grants type qualifiers a new property—they now are idempotent! While this sounds like a powerful claim, all it really means is that you can use the same qualifier more than once in a declaration, and the superfluous ones are ignored:

const const const int n = 6; // same as const int n = 6;

This makes it possible, for example, for the following sequence to be accepted:

 typedef const ...

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.