+ 2

What is a pre-processor directive ?

12th May 2018, 5:32 PM
Aashutosh Swami
Aashutosh Swami - avatar
3 odpowiedzi
+ 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.
12th May 2018, 6:37 PM
Blade Wolfmoon
Blade Wolfmoon - avatar
+ 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
12th May 2018, 6:42 PM
MsJ
MsJ - avatar
0
Thanks a lot guys
13th May 2018, 2:10 AM
Aashutosh Swami
Aashutosh Swami - avatar