Takashi Iwai wrote: > > Adding another macro (like snd_assert in alsa-driver) instead of > standard assert? The behavior can be dependent upon the compile > condition, i.e. with full debug message, return only, replaced with > the normal assert macro, or even ignored. > > const char *snd_pcm_name(snd_pcm_t *pcm) > { > snd_assert(pcm, return NULL); > return pcm->name; > } > > /* replace with assert */ > #define snd_assert(expr, ...) assert(expr) > > /* debug message and action */ > #define snd_assert(expr, ...) do {\ > if (!(expr)) {\ > fprintf(stderr, "alsa-lib assert: %s in %s\n",\ > __STRING(expr), __PRETTY_FUNCTION__);\ > __VA_ARGS__;\ > }\ > } while (0) > > /* action only */ > #define snd_assert(expr, ...) do {\ > if (!(expr)) { \ > __VA_ARGS__;\ > }\ > } while (0) > > /* ignore check */ > #define snd_assert(expr, ...) /**/
This is a flexyble solution that I like because we can have many different behaviours (selectable at compilation time): 1) make snd_assert call assert 2) ignore all snd_assert (for efficiency benefits) 3) make snd_assert write a warning and do an action (now impossible) 4) same as 3 without the warning However I'm still convinced that 1) is the right default choice. It's also very important to distinguish programming errors check from bogus user input check and to use different macros. -- Abramo Bagnara mailto:[EMAIL PROTECTED] Opera Unica Phone: +39.546.656023 Via Emilia Interna, 140 48014 Castel Bolognese (RA) - Italy ALSA project http://www.alsa-project.org It sounds good! _______________________________________________ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel