I have a habit of using the following syntax in my compile-time flags:
#if (defined(A) & defined(B))
#if (defined(A) && defined(B))
defined(SOMETHING) yields 0 or 1, so that you're guaranteed 0 or 1 on both sides, it doesn't make a technical difference whether you use
It's mostly about good habits (using
& could carry over to some situation where it would be wrong) and about writing code that is easy to grasp by simple pattern matching. A
& in there causes a millisecond pause while one considers whether it possibly could be a bit-level thing.
On the third hand, you can't use keyword
and, which you ¹can use in ordinary C++ code.
¹ With Visual C++ you can use
and via a forced include of