Wish: Variable Not Used Warning

Walter Bright newshound1 at digitalmars.com
Wed Jul 9 01:49:34 PDT 2008


Here are some horrid examples from my own code which, to please the 
client, had to compile with all warnings on for MSVC:

---
   p = NULL;  // suppress spurious warning
---
   b = NULL;  // Needed for the b->Put() below to shutup a compiler 
use-without-init warning
---
   #if _MSC_VER
   // Disable useless warnings about unreferenced formal parameters
   #pragma warning (disable : 4100)
   #endif
---
   #define LOG 0       // 0: disable logging, 1: enable it

   #ifdef _MSC_VER
   #pragma warning(disable: 4127)      // Caused by if (LOG)
   #endif // _MSC_VER
---

Note the uglification this makes for code by forcing useless statements 
to be added. If I hadn't put in the comments (and comments are often 
omitted) these things would be a mystery.



More information about the Digitalmars-d mailing list