Using ifndef and define | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Using ifndef and define

I meet question which asked of one of they to using ifndef and defines in good wuality code. But why they formulated like other ways don't exist? Sometimes C++ used for projects which have hard requirements to size and compatibale it may be useful to using compile with flags to crop code.

10th Apr 2017, 6:47 AM
Svetlana Kalinnikova
Svetlana Kalinnikova - avatar
2 Answers
+ 1
While nextco has a good use of it, they allow things to be chosen depending on the flags set at compile time, etc. As a worded example, this can be used to have OS-/arch-specific code instead of having to take the Lowest Common Denominator approach to support all the wanted platforms, or require users of different OSes to install something just to make it run, which that extra something may not even exist for them.
4th Jan 2018, 12:17 AM
Katie (Ctrl-Alt-Cuteness)
Katie (Ctrl-Alt-Cuteness) - avatar
0
Mainly i used for debug code, instead of comment-uncomment a lot of lines, just add compiler vars i like that.
10th Apr 2017, 9:55 AM
nextco
nextco - avatar