liveBook · Manning

Predeclared identifier

As explained in Modern C

A predeclared identifier is an identifier whose declaration is supplied by the language or its standard library rather than written at its point of use.

In C, some names can be used without a declaration written at the point of use. Their declarations are supplied by the language or standard library through header files. For example, printf comes from stdio.h, while size_t and EXIT_SUCCESS come from stdlib.h. TAKEAWAY: a predeclared identifier still requires the compiler to receive its declaration. section 2.2

Declarations hidden behind headers

A program may contain: #include <stdio.h> #include <stdlib.h> int main(void) { size_t i = 0; printf("%zu\n", i); return EXIT_SUCCESS; } The visible program uses printf, size_t, and EXIT_SUCCESS without declaring them locally. The headers provide information corresponding to declarations such as printf's function declaration, size_t's typedef, and EXIT_SUCCESS's macro definition. section 2.2

int printf(char const format[static 1], ...);
typedef unsigned long size_t;
#define EXIT_SUCCESS 0


!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":10}],[{\"line\":0,\"ch\":11},{\"line\":0,\"ch\":21}],[{\"line\":0,\"ch\":29},{\"line\":0,\"ch\":35}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":21}],[{\"line\":1,\"ch\":22},{\"line\":1,\"ch\":28}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":7}],[{\"line\":2,\"ch\":8},{\"line\":2,\"ch\":20}]]"}
!@%STYLE%@!

Inspect representative declarations for printf, size_t, and EXIT_SUCCESS, including a function declaration, typedef, and macro. section 2.2

How Modern C covers it

How deep it goes
Defines the mechanism and shows representative declarations, but defers detailed semantics to platform documentation and the C standard.
Examples
Uses printf from stdio.h and size_t and EXIT_SUCCESS from stdlib.h as concrete examples.
What it assumes
Assumes basic C declarations and identifiers while distinguishing names, objects, types, and values.
What you can do after
Evaluate which headers supply standard-library identifiers and where to seek their precise semantics.
How it connects
Connects predeclared identifiers with declarations, header files, standard libraries, typedefs, macros, and the C standard.

Related concepts

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