This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] timers, pointers to functions and type safety


On Fri, Dec 01, 2006 at 07:57:51PM -0800, Andrew Pinski wrote:
> On Fri, 2006-12-01 at 17:21 +0000, Al Viro wrote:
> > The thing is, absolute majority of callbacks really want a pointer to
> > some object.  There is a handful of cases where we really want a genuine
> > number - not a pointer cast to unsigned long, not an index in array, etc.
> > They certainly can be dealt with.  Nearly a thousand of other instances
> > definitely want pointers.
> 
> Then create an union which contains the two different types of call
> back.
> You know:
> union a
> {
>   void (*callbackwithulong) (unsigned long);
>   void (*callbackwithptr) (void*);
> };
> 
> And then you just use the correct in the correct place.

And you do that how?  The timer code has no way of knowing which of
the two should be used.  Adding a flag, including the associated
storage, to choose between two code paths identical at the assembly
level is not really a good solution.

  OG.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]