[LUGOS-PROG] DEBUG makro(ponovno)

Rok Papež rok.papez at lugos.si
Thu Oct 31 11:13:46 CET 2002


Zivjo!

Dne nedelja 27. oktober 2002 13:35 je Luka Napotnik napisal(a):

> Zanima me, če se še kdo spomne enega DEBUG makra, ki je že krožil pr
> mailing-listi. Sem gledal po arhivu, pa nisem našel.

Pripenjam kar velik kos iz svojih sourceov. Mislim, da bos nasel kar isces.
Btw.: izklopi si lom vrstice (line wrap).

/* ifdebug */
#ifdef DEBUG
#define ifdebug() if(1)
#else
#define ifdebug() if(0)
#endif

#ifdef DEBUG
#define assert(cond) \
  do { \
    if (!(cond)) { \
      err_debug(0, "CRITICAL ERROR: Assertion failed: (%s) in file: %s function: %s() line %d. "\
                   "Source file date: \"%s\"", \
                    __STRING(cond), __FILE__, __FUNCTION__, __LINE__, __DATE__ \
               ); \
      abort(); \
    } \
  } while(0)
#else
#define assert(cond) ;
#endif

/* err_debug - requires ISO C99 */
#define err_debug(level, ...) \
  do { \
    if(level <= err.debug_level) syslog(LOG_INFO, __VA_ARGS__); \
  } while(0)


-- 
best regards,
Rok Papež.




More information about the lugos-prog mailing list