+ 2
What is a pre-processor directive ?
3 Réponses
+ 2
It's a line of a code starting with #.
It gives instructions to the pre-processor on how to act. I would call it a preparation before compilation. eg #include <iostream> basically copies and pastes some C++ library code into your own .cpp file. #pragma once prevents duplicated copies and pastes in the same file twice.
+ 1
Preprocessor directives are lines included in a program that begin with the character #, which make them different from a typical source code text. They are invoked by the compiler to process some programs before compilation.
#include: for including the standard library's
#define and #undef: To define and undefine conditional compilation symbols, respectively. These symbols could be checked during compilation and the required section of source code can be compiled.
#if, #elif, #else, and #endif: To skip part of source code based on conditions.
#line: To control line numbers generated for errors and warning.
#error and #warning : To generate errors and warnings, respectively. #error is used to stop compilation, while #warning is used to continue compilation with messages in the console.
ect
0
Thanks a lot guys