g_assert vs. g_return[_val]_if_fail



Hi all,

We are using glib all over our project (GNU Enterprise) and want to make best use of it's debugging functions.

Now the discussion has started on in which cases g_assert should be used and in which g_return... is better.

We know the differences:
* g_assert is turned off by a different define than g_return..., but both can be turned off. * 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. * for users, it seems that g_return... is nicer because it doesn't kill the process.

So my questions are:
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?
How do others handle this?

Thanks a lot,
--
Reinhard Mueller
GNU Enterprise project
http://www.gnue.org





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