Preprocessor Macros

Lesson overview

Topics covered: #define with arguments, ## token pasting, # stringification, object-like.

Preprocessor Macros

#define MAX(a,b) ((a) > (b) ? (a) : (b)) - macro with args
#define SQR(x) ((x) * (x)) - safe macro
#ifndef HEADER_H / #define HEADER_H / #endif - include guards
#error and #pragma directives

Article author: Arthur Isaev

Banner image