Re: G_ARRAY_LENGTH for glib.h?



On Mon, 24 Jan 2000, Sebastian Wilhelmi wrote:

> 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. 

the compiler can't do any such things at compile time.

> > 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.

not that i remember.

> > 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.

sorry, i don't follow, the same example doesn't work for -O1 as well,
would please try to actually get it compiled?

> 
> Bye,
> Sebastian

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]