C Preprocessor and Macros
C Preprocessor and Macros
Conditional compilation, include guards, predefined macros, macro forms, and the main preprocessor directives in C and C++.
C Preprocessor and Macros
Conditional compilation, include guards, predefined macros, macro forms, and the main preprocessor directives in C and C++.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
#include#define#undef#if#ifdef#ifndef#elif#else#endif#error#line#pragma#define BUFFER_SIZE 1024
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define STR(x) #x
#define JOIN(a, b) a##b
__FILE____LINE____DATE____TIME____STDC____STDC_VERSION____cplusplus in C++ translation units#ifndef WIDGET_H
#define WIDGET_H
/* declarations */
#endif
Modern C++ code may also use #pragma once, but include guards remain the portable baseline pattern.
#pragma onceconstexpr instead of constant-like macrosenum or enum class instead of groups of integer macrosint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}