[80] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] g_assert() is #*!(

daemon@ATHENA.MIT.EDU (Tim Janik)
Sun May 11 02:01:57 1997

Date: Sun, 11 May 1997 07:48:35 +0200 (CEST)
From: Tim Janik <Tim.Janik@Hamburg.Netsurf.DE>
To: |gtk mailing list <gtk-list@redhat.com>
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com



humpf, i just trapped a code sequence like this

{
gpointer a;
a=NULL;

if (!a)
	g_assert(!a);
else
	g_assert(a);
}

on the first look this should work but:

#define g_assert(expr) \
     if (!(expr))                                    \
       g_error ("file %s: line %d (%s): \"%s\"",     \
                __FILE__,                            \
                __LINE__,                            \
                __PRETTY_FUNCTION__,                 \
                #expr)

because of the "if () g_error()"; definition both lines,
the
	g_assert(!a);
and
	g_assert(a);

get executed.

what about:

#define g_assert(expr) { \
     if (!(expr))                                    \
       g_error ("file %s: line %d (%s): \"%s\"",     \
                __FILE__,                            \
                __LINE__,                            \
                __PRETTY_FUNCTION__,                 \
                #expr) }

comments, suggestions, flames, comfort?



---
ciaoTJ

Tim.Janik@Hamburg.Netsurf.DE	[signature: <CENS||ED>]

--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post