C CLP key terms
C CLP · Get comfortable with the vocabulary.
- translation unit
- Related: preprocessor, linkage
The complete source text a compiler processes in one pass: a source file after preprocessing, with all #include files expanded and all macros replaced. Separate translation units are later combined by the linker.
- preprocessor directive
- Related: macro expansion, include guard
A line beginning with # that the preprocessor handles before compilation, such as #include, #define, #if, or #pragma. Directives are not C statements and do not end with a semicolon.
- macro expansion
- Related: preprocessor directive, stringizing operator
The textual substitution the preprocessor performs for an object-like or function-like macro. Arguments are substituted textually, not evaluated, so parentheses and side-effect caution are essential.
- include guard
- Related: preprocessor directive, translation unit
A conditional pattern using #ifndef, #define, and #endif around a header's contents so that repeated inclusion in one translation unit does not redeclare the same types or macros.
- stringizing operator
- Related: macro expansion, token pasting
The # token inside a macro definition that converts the corresponding argument into a string literal without evaluating it. It is applied before the ## token-pasting operator.
- token pasting
- Related: stringizing operator, macro expansion
The ## operator inside a macro definition that glues the text of two adjacent tokens into a single token, commonly used to build identifier names from macro arguments.
- object representation
- Related: alignment, strict aliasing
The sequence of bytes a particular implementation uses to store a value of a type. It may include padding bits and differs from the value representation, which describes meaningful bits.
- integer conversion rank
- Related: usual arithmetic conversions, integer promotion
An ordering of integer types by precision where long long ranks above long, long above int, and so on. The rank decides which operand is converted in usual arithmetic conversions.
- integer promotion
- Related: integer conversion rank, usual arithmetic conversions
The automatic conversion of a small integer type such as char, short, or an enumeration to int or unsigned int before use in arithmetic or as a variadic argument.
- usual arithmetic conversions
- Related: integer promotion, integer conversion rank
The rules that bring two operands of a binary arithmetic operator to a common type, based on rank, signedness, and whether the unsigned type can represent all values of the signed one.
- strict aliasing
- Related: object representation, effective type
The rule that an object may normally be accessed only through an lvalue of its own type, a qualified version, a signed or unsigned counterpart, an aggregate containing it, or a character type. Violating it permits aggressive optimization.
- effective type
- Related: strict aliasing, malloc
For dynamically allocated objects, the type established by the last store into the object, or the declared type of a copied source. It constrains which lvalues may legally access the storage.
- sequence point
- Related: undefined behavior, short-circuit evaluation
A point in program execution where all side effects of previous evaluations are complete and none of subsequent evaluations have begun. The C standard specifies a finite set of such points.
- short-circuit evaluation
- Related: sequence point, conditional operator
The guarantee that the right operand of && is not evaluated when the left is false, and the right operand of || is not evaluated when the left is true. The comma and conditional operators also impose ordering.
- lvalue
- Related: rvalue, address-of operator
An expression that designates an object and may appear on the left of an assignment, though not all lvalues are modifiable. Arrays and const-qualified objects are non-modifiable lvalues.
- conditional operator
- Related: short-circuit evaluation, lvalue
The ternary operator ?: that evaluates its first operand, then exactly one of the other two, and yields a value converted to their common type. It is not an lvalue in C.
- comma operator
- Related: sequence point, short-circuit evaluation
An operator that evaluates its left operand, discards the result, then evaluates the right operand and yields that value. It introduces a sequence point between the operands.
- undefined behavior
- Related: sequence point, strict aliasing
Behavior for which the C standard imposes no requirements, such as signed overflow or dereferencing a null pointer. Compilers may assume it never occurs and optimize accordingly.
- dangling else
- Related: compound statement, switch statement
The ambiguity in nested if statements where an else binds to the nearest unmatched if. Braces should be used to make the intended association explicit.
- switch statement
- Related: dangling else, compound statement
A selection statement that transfers control to a case label matching the controlling integer expression. Without break, execution falls through into subsequent cases.
- compound statement
- Related: scope, dangling else
A brace-enclosed sequence of declarations and statements that forms a block and introduces a new scope. It may be used anywhere a single statement is permitted.
- variadic function
- Related: default argument promotions, function prototype
A function declared with an ellipsis in its parameter list that accepts a variable number of arguments. The callee retrieves them with va_start, va_arg, and va_end from stdarg.h.
- default argument promotions
- Related: variadic function, integer promotion
The conversions applied to arguments of a variadic function or a function without a prototype: float becomes double, and small integer types are promoted to int or unsigned int.
- function prototype
- Related: variadic function, linkage
A declaration that specifies a function's return type and parameter types, enabling the compiler to check calls and apply correct conversions. It ends with a semicolon and contains no body.
- linkage
- Related: storage duration, static storage duration
The property determining whether an identifier declared in one translation unit denotes the same entity as one declared in another. External linkage is shared; internal and no linkage are not.
- storage duration
- Related: linkage, static storage duration
The lifetime category of an object: automatic, static, or allocated. It determines when storage is reserved and released, independent of the identifier's scope.
- static storage duration
- Related: storage duration, linkage
Storage that exists for the entire execution of the program. Objects at file scope, and local objects declared with static, are zero-initialized before program startup.
- scope
- Related: storage duration, compound statement
The region of program text in which an identifier is visible. C defines block, file, function prototype, and function scopes; inner declarations can hide outer ones.
- array-to-pointer decay
- Related: pointer arithmetic, multidimensional array
The implicit conversion of an array expression, except as the operand of sizeof, _Alignof, or the address-of operator, to a pointer to its first element when used in most contexts.
- pointer arithmetic
- Related: array-to-pointer decay, one-past-the-end pointer
Addition or subtraction on a pointer scaled by the size of the pointed-to type. The result is defined only within the same array object or one past its final element.
- one-past-the-end pointer
- Related: pointer arithmetic, undefined behavior
A pointer to the element immediately after the last element of an array. It may be formed and compared, but dereferencing it is undefined behavior.
- multidimensional array
- Related: array-to-pointer decay, pointer arithmetic
An array whose elements are themselves arrays. Its name decays to a pointer to the first row, so a parameter must declare the trailing dimensions, as in int a[][4].
- null-terminated string
- Related: strcpy, string literal
A sequence of characters stored in a char array and terminated by a null character. Library functions such as strlen and strcpy rely on this terminator to find the end.
- string literal
- Related: null-terminated string, strcpy
A double-quoted sequence of characters that denotes a static array of char, including an implicit terminating null. Modifying one through a pointer is undefined behavior.
- strcpy
- Related: null-terminated string, buffer overflow
A standard library function that copies a null-terminated source string into a destination buffer. It performs no bounds checking, so the destination must be large enough.
- buffer overflow
- Related: strcpy, malloc
Writing past the end of an allocated array or buffer, corrupting adjacent memory. It is a common source of crashes and security vulnerabilities in C programs.
- malloc
- Related: free, effective type
A standard library function that allocates a block of uninitialized storage of a requested size and returns a pointer to it, or a null pointer on failure.
- free
- Related: malloc, dangling pointer
A library function that releases storage previously obtained from malloc, calloc, or realloc. Freeing the same pointer twice, or freeing a non-heap address, is undefined behavior.
- dangling pointer
- Related: free, use after free
A pointer that still holds the address of storage that has been freed or has gone out of scope. Dereferencing it is undefined behavior even if the memory appears intact.
- use after free
- Related: dangling pointer, free
Accessing memory through a pointer after the pointed-to block has been released. The behavior is undefined and often silently corrupts unrelated data.
- alignment
- Related: object representation, bit-field
A requirement that an object's address be a multiple of some power of two, determined by its type. Misaligned access may be slow or illegal depending on the platform.
- bit-field
- Related: alignment, union
A structure member declared with an explicit width in bits. Layout and ordering are implementation-defined, and the address-of operator cannot be applied to a bit-field.
- union
- Related: bit-field, alignment
A type whose members share the same storage, so only one member's value is meaningful at a time. Reading a member other than the last written is implementation-defined except in specific cases.
- enumeration constant
- Related: integer promotion, union
A named integer constant declared inside an enum. Its type is int in C, and successive constants increase by one unless explicitly assigned.
- fopen
- Related: fclose, fseek
A standard library function that opens a file in a specified mode such as "r" or "wb" and returns a FILE pointer, or a null pointer if the open fails.
- fclose
- Related: fopen, fflush
A library function that flushes buffered output and releases the resources associated with a FILE stream. Failing to close streams can lose buffered data.
- fseek
- Related: fopen, fflush
A library function that repositions a stream's file position indicator using an offset and one of SEEK_SET, SEEK_CUR, or SEEK_END. It requires a seekable stream.