Contenido del Curso
C Preprocessing
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.
main
#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.
¡Gracias por tus comentarios!