gnucash master: Add failing unittest for aqbanking lookup of trans_retrieval date.

John Ralls jralls at ceridwen.us
Mon Sep 8 15:59:45 EDT 2014


On Sep 8, 2014, at 11:16 AM, Christian Stimming <christian at cstimming.de> wrote:

> Am Montag, 8. September 2014, 07:17:47 schrieb John Ralls:
>> On Sep 8, 2014, at 5:31 AM, Christian Stimming <christian at cstimming.de> 
> wrote:
>>> Zitat von John Ralls <jralls at ceridwen.us>:
>>>>> recently I noticed the "trans-retrieval" slot in the aqbanking account
>>>>> doesn't remember its value.
>>>> 
>>>> Christian,
>>>> 
>>>> Yeah, fixed and pushed, e210f8c.
>>>> 
>>>> The difference was that your test used the defective accessor function
>>>> and mine used qof_instance_get directly with the right parameter type
>>>> (Timespec ** instead of Timespec *).> 
>>> Ah, the wonders of zero compile-time checks of variable argument lists in
>>> C...
>>> 
>>> Thanks a lot for fixing this!
>> 
>> It's not C's fault; C compiler's know the difference between pointers and
>> pointers-to-pointers and how to raise type errors. It's GValue's conversion
>> of everything to void* that defeats the type checking.
> 
> Err... no, it is indeed C's fault: The function in question, qof_instance_get 
> and set, uses a variable argument list (variadic arguments), terminated by the 
> NULL pointer in the call, and this variable arguments are not at all compile-
> time checked. Using qof_instance_get is what you inserted here in 
> 272655b60c0e30726, including the bug you fortunately now fixed. If there is 
> another interface that gives us some more compile time checking, feel free to 
> propose it here and/or in the docs of qof_instance_get. Or is this just a 
> fundamental (bad) property of g_object's property system that we can't avoid?

It’s a fundamental bad property of variadic functions in general, but if the variadic function was calling a strongly-typed function (inside GObject, since qof_instance_get just wraps g_object_get) the compiler would have errored out. Since the GValue functions take void*, the compiler didn’t have a chance.

The interface which gives more compile-time checking uses templates instead of void*, at the expense of some really horrendous compiler error messages. Boosters of the new concepts feature due in C++17 and available in boost claim that it fixes the compiler error problem, but I haven’t tried it yet to see if they’re right.

I think replacing GObject properties and GValues will be part of converting the primary database classes to C++.

Regards,
John Ralls





More information about the gnucash-devel mailing list