Re: #50205 - GCallback should not be a void pointer



On 28 Mar 2001, Owen Taylor wrote:

> 
> Tim Janik <timj gtk org> writes:
> 
> > On 26 Mar 2001, Owen Taylor wrote:
> > 
> > > 
> > > Having GCallback be a void * is particularly evil because
> > > casts between void * and are function pointer are not allowed
> > > by ANSI C, but gcc -Wall doesn't warn about them.
> > > 
> > > So, this is just an open invitation for people to write 
> > > code that is not portable to compilers other than gcc.
> > > 
> > > Providing a real function pointer typedef for GCallback
> > > will force people to use the G_CALLBACK() macro.
> > > 
> > > Can I commit?
> > 
> > what's bad about typedef void (*GCallback) (); special cased
> > for non-c++ use use?
> 
>  a) Special casing for C++ is evil. For example, older versions of
>     G++ are buggy and treat empty parens inside extern "C" in the C 
>     manner, unless -pedantic is specified. This causes code compiled
>     with -pendantic to have different mangling.

for c++ this would be (void)

>  b) Empty parens to mean "unspecified" is IIRC explicitely deprecated
>     in C99.

i don't really buy into that, since virtually any ANSI compiler out there
supports it.

> 
> Regards,
>                                         Owen
> 

---
ciaoTJ





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