Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 26 of 50 · c

Preprocessor Directives

Duration: 9 mins

The preprocessor runs before compilation and handles macros, file inclusion, and conditional compilation.

#define PI 3.14159
#define SQUARE(x) ((x)*(x))

#if defined(_WIN32)
    #define PLATFORM "Windows"
#else
    #define PLATFORM "Other"
#endif

Common directives:

  • #include "file.h" – include header.
  • #define / #undef – macros.
  • #if, #ifdef, #ifndef, #else, #elif, #endif – conditional compilation.
  • #pragma – implementation‑specific instructions.

Macros are textual replacements; they are not type‑checked. Use static inline functions for safer alternatives when possible.

Previous: File I/O (`stdio.h`)Next: Header Files & Multiple Translation Units