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



Tim Janik <timj gtk org> writes:

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

Yes, () means (void) in C++. 

 * Having GCallback be (void) in C++ and unspecificied in C is evil.

 * Having GCallback be (void) in C++ and unspecificied in C causes
   problems with older versions of G++, which interpret () differently
   in extern "C" {}.
 
> >  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.

6.11.6 Function declarators 
 
  The use of function declarators with
  empty parentheses (not prototype-format parameter type declarators) is
  an obsolescent feature.

Regards,
                                        Owen




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