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





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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]