Re: GtkArg typesafety
- From: George <jirka 5z com>
- To: gnome-devel-list gnome org
- Subject: Re: GtkArg typesafety
- Date: Tue, 4 Jan 2000 17:19:12 -0800
On Tue, Jan 04, 2000 at 12:02:05PM -0500, Havoc Pennington wrote:
> IMO this is much extra complexity for very little gain (it avoids the
> "0" is not a double problem, but that's all really; it doesn't solve
> the problem of passing entirely the wrong type or getting const-ness
> wrong). And it ruins the nice syntax which is 85% of the point of
> arguments.
Ok, added full type safety, so with this, using args is just as type safe as a
normal function call.
#ifdef __GNUC__
#define MY_PERSON_ARG_NAME(arg) "name",({char *z = (arg); z;})
#define MY_PERSON_GET_ARG_NAME(arg) "name",({char **z = (arg); z;})
#define MY_PERSON_ARG_DOB(arg) "dob",({glong z = (arg); z;})
#define MY_PERSON_GET_ARG_DOB(arg) "dob",({glong *z = (arg); z;})
#define MY_PERSON_ARG_DOD(arg) "dod",({glong z = (arg); z;})
#define MY_PERSON_GET_ARG_DOD(arg) "dod",({glong *z = (arg); z;})
#else /* __GNUC__ */
#define MY_PERSON_ARG_NAME(arg) "name",(char *)(arg)
#define MY_PERSON_GET_ARG_NAME(arg) "name",(char **)(arg)
#define MY_PERSON_ARG_DOB(arg) "dob",(glong )(arg)
#define MY_PERSON_GET_ARG_DOB(arg) "dob",(glong *)(arg)
#define MY_PERSON_ARG_DOD(arg) "dod",(glong )(arg)
#define MY_PERSON_GET_ARG_DOD(arg) "dod",(glong *)(arg)
#endif /* __GNUC__ */
This not only casts, but gives a warning even on wrong pointer types. I'm
really starting to like GNU C extentions.
George
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]