Re: G_ARRAY_LENGTH for glib.h?
- From: Sebastian Wilhelmi <wilhelmi ira uka de>
- To: gtk-devel-list redhat com
- Subject: Re: G_ARRAY_LENGTH for glib.h?
- Date: Mon, 24 Jan 2000 13:05:26 +0000
Hi Tim,
> even if this *would* work, i wouldn't put it in glib.h, simply because
> 1) the test is not fully reliable (try it with gpointer p = &p;)
This would fail as well, because the compiler wouldn't notice at compile-time,
that p is equal &p.
> 2) the macro is provided for convenience of people so far doing
> sizeof (array) / sizeof (array[0]), and those already know
> that this kind of thing only works for arrays
True, but wasn't it you, who pointed out, that it would be nice to have a
check to prevent this case.
> 3) programmers using macros should at least have a remote idea about
> what the macro is intended for (MAX as defined in glib.h doesn't
> produce sane results for MAX (y++, ++x) either)
That's true.
> 4) your definition simply doesn't work, try compiling the following
> example:
Yeah, thats why I used #if defined(__GNUC__) && defined(__OPTIMIZE__),
which isn't defined in your example.
Bye,
Sebastian
--
Sebastian Wilhelmi | här ovanför alla molnen
mailto:wilhelmi@ira.uka.de | är himmlen så förunderligt blå
http://goethe.ira.uka.de/~wilhelmi |
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]