I've been trying to google this for a while now but I can't seem to be able to find any clear answer if it can be done at all.
I wanted to know if it's possible to do a MultiLine #if statement in C++ in a similar way to this type of if
if (
1 == 1 ||
2 == 2 ||
3 == 3
) {
cout << "True\n";
}
I was hoping for something along the lines of (which I know is hopelessly wrong)
#if
1 == 1 ||
2 == 2 ||
3 == 3
#then
cout << "True\n";
#else
cout << "False\n";
#endif
#if \
1 == 1 || \
2 == 2 || \
3 == 3
cout << "True\n";
#else
cout << "False\n";
#endif
Backslash-newline combinations are stripped very early in preprocessing, even before tokenizing the input. You can use this to spread preprocessor directives across multiple physical lines.
Heck, you could theoretically even do
#i\
f 1 == 1 |\
| 2 == 2 || 3 =\
= 3
but then your colleagues might get upset with you.
Yes. With continuation lines:
#if \
1 == 1 || \
2 == 2 || \
3 == 3
cout << "True\n";
#else
cout << "False\n";
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With