Comments

// line comment
/* block
   comment */

Preprocessor Directives

File Inclusion

// from /usr/include or other path provided by -I/path/to/files.
#include <system_file>

// from .
#include “user_file.h”

Macro Definition

#define IDENTIFIER \
        replacement list

#define IDENTIFIER([parameter][, ...]) replacement list

#undef IDENTIFIER

Define requires ( to immediately proceed the identifier.

Conditional Compilation

#if [!]constant expression
    ...
#elif [!]constant expression
    ...
#else
    ...
#endif

#if defined(IDENTIFIER)
#if defined IDENTIFIER
#ifdef IDENTIFIER
#ifndef IDENTIFIER

Predefined Macros

__LINE__ Current line number being compiled.
__FILE__ Current name of file being compiled.
__DATE__ Date of compilation.
__TIME__ Time of compilation.

Stringization

#define print_int(x) printf(#x " = %d", x)

Token Pasting

#define VAR_ID(n) var##n
int VAR_ID(1); // becomes int var1;

Error Directive

#error message // Compiling stops and displays message.

Pragma Directive