Re: g_assert vs. g_return_if_fail
- From: LRN <lrn1986 gmail com>
- To: Jiří Zárevúcky <zarevucky jiri gmail com>
- Cc: Gtk+ <gtk-list gnome org>
- Subject: Re: g_assert vs. g_return_if_fail
- Date: Thu, 21 Jan 2010 00:41:57 +0300
On 21.01.2010 0:38, Jiří Zárevúcky wrote:
> Behdad Esfahbod píše v St 20. 01. 2010 v 13:18 -0500:
>
>> On 01/20/2010 02:03 PM, Martin Kalbfuß wrote:
>>
>>> Thanks,
>>>
>>> But why is it a disastrous idea?
>>>
>>> When It's a clear programming error, why not abort the program with
>>> g_assert?
>>>
>> Because that can cause user data loss.
>>
>> behdad
>>
>>
>>
> So there are two possibilities: g_assert when you want the application
> to abort, and g_return_if_fail when you don't. g_assert can be disabled
> compile-time for a release, right? In that case, it does nothing.
>
> So why not add a compile option to make g_return_if_fail fatal, and
> simply deprecate g_assert? What is the point of having it there?
>
Myself, i've always viewed g_return_if_fail as a convenience macro that
i could use instead of if (!blah) { g_log_warning(bar); return foo; }.
And, AFAIK, it also logs warnings.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]