[Mesa-dev] [PATCH] mesa: do not define NDEBUG to make sure assert work
Yuanhan Liu
yuanhan.liu at linux.intel.com
Sat Oct 8 02:41:58 PDT 2011
On Sat, Oct 08, 2011 at 02:17:29AM -0700, Kenneth Graunke wrote:
> On 10/08/2011 02:08 AM, Yuanhan Liu wrote:
> > If you include "mtypes.h", which would define macro NDEBUG, before
> > including "compiler.h", you would find that the assert macro will no
> > longer work; it just make it slient by replacing it with ((void) (0));
> >
> > Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
> > ---
> > src/mesa/main/mtypes.h | 3 ---
> > 1 files changed, 0 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> > index 749324d..5edecf2 100644
> > --- a/src/mesa/main/mtypes.h
> > +++ b/src/mesa/main/mtypes.h
> > @@ -3336,9 +3336,6 @@ extern int MESA_DEBUG_FLAGS;
>
> Isn't this intentional? To give some context to the patch:
>
> #ifdef DEBUG
> extern int MESA_VERBOSE;
> extern int MESA_DEBUG_FLAGS;
> # define MESA_FUNCTION __FUNCTION__
> #else
> > # define MESA_VERBOSE 0
> > # define MESA_DEBUG_FLAGS 0
> > # define MESA_FUNCTION "a function"
> > -# ifndef NDEBUG
> > -# define NDEBUG
> > -# endif
> > #endif
>
> So NDEBUG only gets defined if !DEBUG. In other words, assertions
> happen if you build with --enable-debug, but not in release mode (since
> it's extra overhead).
Thanks for the explanation. I thought assertion is a must. But from your
point, it's just for debug purpose.
Thanks,
Yuanhan Liu
More information about the mesa-dev
mailing list