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
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Preprocessor Directives | C Programming Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 26 of 50

·c

Preprocessor Directives

9 mins

Course progress52%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `#include <stdio.h>` brings a system header; quotes `"file.h"` search local directory first.
  • `#define` creates a macro; parentheses are essential for function‑like macros.
  • Conditional compilation (`#ifdef`) allows platform‑specific code.
  • `#pragma once` or include guards prevent multiple inclusion.

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.

Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from C Programming FundamentalsBrowse activities
Previous lessonFile I/O (`stdio.h`)Continue to lesson 27Header Files & Multiple Translation UnitsBack to C Programming Fundamentals curriculum