version and version_check

Derek Atkins warlord at MIT.EDU
Sun Aug 15 15:41:47 EDT 2004


Neil Williams <linux at codehelp.co.uk> writes:

> Isn't QOF_TYPE_INT32 useful for gint? Particularly for these enum values where 
> the maximum is about 12 or for gncBillTermGetDueDays. The merge isn't just 
> working on user-serviceable parts, I need to be able to set and get every 
> part of each object, subject to those parameters that are calculated fields, 
> otherwise some objects will be left with corrupt / incomplete parameter data.
>
> business/business-core/gncBillTerm.h:Uses a standard gint (QOF_TYPE_INT32) to 
> set the enumerator

*ponders*

Enums generally aren't "generic", but I can somewhat see your point.
Perhaps we should just have a QOF_TYPE_ENUM that is an 'int' and
useful for enums.

[snip]
>> > Is this satisfactory? (Is it unnecessary?)
>>
>> Yes, it is not necessary.  You can pass an int into an enum.
>
> What about the return value? If I use a get_fcn that returns a GncBillTermType 
> can I rely on implicit casting to a gint or are there situations where it's 
> safer to use an explicit cast, as here:
>
> gint gncBillTermGetType_q (GncBillTerm *term)
> {
> 	if(!term) return 0;
> 	return (gint)gncBillTermGetType(term);
> }

See the C standard.  an enum == int.  It will get casted properly.
You don't need to cast it manually.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list