Hi All, On Sat, Feb 23, 2013 at 3:41 AM, Andreas Färber <afaer...@suse.de> wrote: > Am 22.02.2013 17:54, schrieb Richard Henderson: >> On 02/22/2013 08:16 AM, Andreas Färber wrote: >>> I would be willing to do a macro-based v3 using do { ... } while (0) if >>> maintainers can reach agreement on that and on how to do the if (0). >> >> FWIW, I'm in favor of the >> >> #ifndef DEBUG >> # define DEBUG 0 >> #endif >> #define MACRO_NAME(...) \ >> do { if (DEBUG) { log(...) } } while (0) >>
+1. I already have a series on list (Zynq I2C) doing exactly this on 3 new device models: http://comments.gmane.org/gmane.comp.emulators.qemu/195651 Example below: + +#ifndef PCA9548_DEBUG +#define PCA9548_DEBUG 0 +#endif +#define DB_PRINT(fmt, args...) do {\ + if (PCA9548_DEBUG) {\ + fprintf(stderr, "PCA9548: "fmt, ## args);\ + } \ +} while (0); + Regards, Peter >> sort of solution. Immediate constant into the IF, which even an -O0 >> compile will delete as dead. > > I remember there being complaints about me changing in-code #ifdefs to > #ifs in v1 as a consequence... some naming convention like #ifdef DEBUG > #define DEBUG_ON 1 #else #define DEBUG_ON 0 or so would address that. > Let's wait for some more feedback. > > Andreas > > -- > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg >