BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C Preprocessor Directives

By Chaitanya Singh | Filed Under: c-programming

C preprocessor is a macro processor, which is used by the compiler to make the appropriate changes to the code before the compilation begins.

C preprocessors are not part of the compiler, it is just an additional step that is performed by the C compiler before the compilation. As the name suggests, it instructs the compiler to do some pre-processing before the actual compilation.

All the preprocessor commands begin with the # symbol. The preprocessor directive should always be the first line of the C program.

C Preprocessor directives

#include – Inserts a specified header file into the code. It basically copies the code of specified header file and paste it in the current C file.

#define – It is used to define constant or substitutes a preprocessor macro.

#undef – Undefined a preprocessor macro. Works opposite to the #define directive. It just un-defines the constant or macro defined by #define directive.

#ifdef – The #ifdef preprocessor directive checks if macro is defined by #define. Returns true, if this macro is defined.

#ifndef – It checks if macro is not defined by #define directive. If yes, it executes the code otherwise code defined in #else directive is executed

#if – It evaluates the expression or condition.

#else – It evaluates the expression or condition if the #if directive condition returns false.

#elif – Combination of #if and #else directives.

#endif – Ends the specified preprocessor condition.

#error – Prints error message. The compiler gives fatal error if #error directive is found and skips further compilation process.

#pragma – It is used to issue special commands or additional information to the compiler.

C Programming Tutorial

  • C Tutorial
  • History of C
  • Features of C
  • Turbo C++ installation
  • First C Program
  • printf scanf
  • Variables in C
  • Data Types in C
  • C - Keywords
  • C Identifiers
  • C Comments
  • Operator precedence
  • C - if statement
  • C - if..else
  • C - for loop
  • C - while loop
  • C - do while loop
  • C - continue
  • C - break statement
  • C - switch..case
  • C - goto statement
  • C - Arrays
  • 2 D array
  • C - String
  • C - functions
  • Function call by reference
  • Function call by value
  • Array to function
  • C - Structures
  • C - Pointers
  • Pointer to Pointer
  • Pointers to functions
  • C - function pointers
  • Pointer & Array
  • C - File I/O
  • C Programming Examples

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap