It’s not in one place, Qt Coding Conventions [qt-project.org] , but others(example [qt.gitorious.org]) seems just copy of that.
In the end
Always check whether a preprocessor variable is defined before probing its value (-Wundef)
#if Foo == 0 // W R O N G *first*
#if defined(Foo) && Foo == 0 // Right *second*
#if Foo - 0 == 0 // Clever, are we? Use the one above instead, for better readability *third*
But if Foo is undefined second is false and third is true, because all undefined identifiers are replaced with literal 0. I checked this will latest Qt Creator and it act so.
↧