If you find yourself constantly commenting and uncommenting bits of code during development, this tip could come in handy.
Normally, you’d do something like this:
#define /* #undef */ _FOObool x = true; // = false;
Instead, use C style commenting to your advantage:
/**/ #define /*/ #undef /**/ _FOObool x = /**/ true /*/ false /**/;
This defines _FOO and sets x to true. Deleting or adding the second slash toggles the comments:
/** #define /*/ #undef /**/ _FOObool x = /** true /*/ false /**/;
This also works when you have large chunks of code you wish to “toggle” and a preprocessor define would be overkill. Keep in mind this makes code harder to read to someone not familiar with the technique, so let your team know how it works and use it sparingly!
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























