Hi, everyone. I got a lot of help from the last question and I have another question.
If you look at the c++ code, there's a code that says #if and it's 1, 0, what's the role?
And when is #endif used?
#if #elif #endif
If it's declared like this, do I have to go through if or elif and end if at the end?
c++
The syntax that starts with #
in C/C++ is a macro classification processed by the preprocessor.
Among them, the #if
statement is paired with #endif
as a conditional statement.
#if
is the start of the branch statement, and #endif
is the end of the if.
#if [Macro-modification]
#endif
If you want to write the else
syntax, write #else
between #if
and #endif
.
#if [Macro-modification]
// If 'Macro Formula' is true when compiling, compile with this part.
#else
// If 'Macro Formula' is false when compiling, compile including this part.
#endif
If you want to branch with multiple conditions, you can use #elif
to:
#if [Macro Formula 1]
#elif [Macro's formula 2]
#elif [Macro's formula 3]
#elif [Macro-modified...]]
#else
#endif
© 2024 OneMinuteCode. All rights reserved.