apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@covalent.net>
Subject Re: Problem with pointer conversion
Date Tue, 08 Jan 2002 02:52:03 GMT
From: "Branko ─îibej" <brane@xbc.nu>
Sent: Monday, January 07, 2002 8:29 PM


> A void pointer is implicitly converted to any other pointer type in C,
> so this cast shouldn't be necessary. Can you be a bit more specific
> about the compiler you're using, the platform, and the error message you
> get?
>
> Christian Gross wrote:
>
> > I was playing around with the HOOK code and noticed a little bug.
> >
> > Consider the macro APR_IMPLEMENT_EXTERNAL_HOOK_BASE and find the line
> >
> > pHook = apr_array_push( _hooks.link_##name);
> >
> > This line causes a compiler fault.  pHook is typedefed, but
> > apr_array_push is a void pointer.  Hence there is compiler problem.  I
> > changed the line to the following
> >
> > pHook = (ns##_LINK_##name@@_t *)apr_array_push( _hooks.link_##name);
> >
> > Then things worked with no problem.  Basically what was missing was a
> > typecast.
> >
> > Could this be added to the APR sources?

No.  It breaks type saftey.

Because you've already created the terrific opportunity to segfault.
This bug on Win32 is usually caused by declaring something without your
own FOO_DECLARE or FOO_DECLARE_NONSTD wrappers (or the wrong case.)

Remember that imported v.s. exported, cdecl v.s. stdcall is PART of the
function declaration.  If you mess this up, you will gp fault.


Mime
View raw message