//* Two slashes for version A, one slash for version B int main() // version A { printf("Version A\n"); } /*/ int main() // version B { printf("Version B\n"); } //*/Works on C/C++/Java/C#. For SQL:
--/* SELECT * FROM A /*/ SELECT * FROM B --*/Remove the -- on the first line to switch to the second block. Now, if anyone knows how to do it in other languages...
Trick two: Nested comments
Some compilers support nested comments (actually, only Borland!). This piece of code helps you detect if the compiler supports nested comments:
#define NESTED /* /* /*/ 0 */*/*/1
main()
{
puts(NESTED ? "Supported" : "Unsupported");
}
No comments:
Post a Comment