Listing 1 A common debugging macro

// .h
#ifdef _DEBUG
void SqlTrace( LPCSTR);
#define TRACESQL(sz) ::SqlTrace(sz)
#else
inline void_cdecl SqlTrace(LPCSTR) { }
#define TRACESQL 1 ? (void)0 : ::SqlTrace
#endif

// .cpp
#ifdef _DEBUG
// tracing strings longer than 512
void SqlTrace(LPCSTR pszSQL)
{
   ASSERT( AfxIsValidString( pszSQL));

   if (afxTraceFlags & 0x20) // if db tracing
   {
      char *pszFormat = "SQL : %s\n";
      int n = strlen( pszSQL);
      char *psz = (char *) pszSQL;
      while (n)
      {
         int n1 = n > 110 ? 100 : n;
         n -= n1;
         char ch = psz[n1];
         psz[n1] = 0;
         AfxTrace( pszFormat, psz);
         psz += n1;
         *psz = ch;
         pszFormat = "... %s\n";
      }
   }
}
#endif

// End of File