Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Preprocessing Commands | Introduction to Preprocessing
C Preprocessing
course content

Contenido del Curso

C Preprocessing

book
Preprocessing Commands

The main tasks of the preprocessor are to perform macro substitutions, link external files, conditional compilation, and perform text substitutions. More precisely, it executes all the directives it finds in the file.

Preprocessing prepares the file for future compilation stages, because, for example, the compiler has no idea what the #include directive is.

Inclusion

The #include directive is used to include the contents of other files into the source code of a program.

Macro Definition

Macros in C allow you to define text substitutions. When the preprocessor finds a macro in the code, it replaces its value with the one specified in the #define directive.

Wherever PI appears in the code, it will be replaced with 3.14159.

Conditional Compilation

Uses a whole set of commands (#if, #ifdef, #ifndef, #else, #elif, #endif) to include or exclude parts of code based on conditions. This is useful when working with platform-dependent code or for debugging.

Defined Macro

In the C programming language, there are special predefined macros that are automatically provided by the compiler.

c

main

copy
1234567
#include <stdio.h> int main() { printf("Number of line: %d\n", __LINE__); return 0; }

These were the main and most frequently used preprocessor directives. In addition to them, there are many more that we will also consider in this course.

Which preprocessor directive should be used for  including new files?

Which preprocessor directive should be used for including new files?

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 3
We're sorry to hear that something went wrong. What happened?
some-alt