Re: g_assert vs. g_return[_val]_if_fail



Reinhard Mueller <reinhard mueller bytewise at> writes:
> * g_assert terminates the application, where g_return... only terminates the function
> * therefore, g_assert lets me jump into gdb as soon as it is hit, while
> g_return... doesn not. This seems to be an advantage for g_assert.

You can always run the app with --g-fatal-warnings to also make
g_return fatal.

> Is there a golden rule when to use which?
> Does it make sense to use both and disable the g_assert for production use and let
> g_return... in?

For GTK, we normally use g_return if the app developer has made a
mistake, and g_assert() if GTK itself is confused.

Havoc




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