On 05/01/2005, at 1:17 PM, William A. Rowe, Jr. wrote:
> At 06:06 PM 1/4/2005, Andre Pang wrote:
>> [...]
>> This doesn't quite work however, because foo_handler is declared to be
>> of the ap_HOOK_handler_t type. Since the ap_HOOK_handler_t typedef is
>> declared in the Apache headers files without __cdecl, the compiler
>> type-checks ap_HOOK_handler_t as __stdcall (because the header files
>> are included by the module, and since the module is compiled with
>> __stdcall, any header declarations are also presumed to be __stdcall).
>
> Let me make sure I understand; you build your module forcing
> the /Gz option?
That's exactly right.
> I'll consider the minimal semantics to force this to behave
> (we have a set of macros, AP[...]_DECLARE_NONSTD) which should
> actually handle this nicely, with the addition of __cdecl.
That sounds perfect to me. I mentioned this in my original message,
too:
>> * Add an AP_MODULE_ENTRY_POINT macro to declare direct function
>> entry points into a module, similar to how AP_MODULE_DECLARE_DATA is
>> needed for module declarations. Or, change the
>> AP_MODULE_DECLARE_NONSTD macro so that it contains __cdecl on
>> Windows.
... so it looks like we're in sync there. Adding __cdecl to
AP_MODULE_DECLARE_NONSTD sounds perfect.
> It's up to you to correctly declare your registered hook
> entry points as __cdecl if you insist on the nonstandard /Gz
> compiler option.
I do correctly declare my hook entry points as __cdecl, but this isn't
quite enough.
The problem is that when the Apache header files are #included by the
module's source code, the ap_HOOK_handler_t and module typedefs expect
__stdcall function pointers (because I'm compiling with /Gz).
Specifically, I mean these parameters:
static void __cdecl foo_register_hooks(apr_pool_t *p)
{
ap_hook_handler(foo_handler /* <-- this function pointer
needs to be typedef'ed as
__cdecl */,
NULL, NULL, APR_HOOK_MIDDLE);
}
and
module AP_MODULE_DECLARE_DATA foo_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-dir config structures */
NULL, /* merge per-dir config structures */
NULL, /* create per-server config structures */
NULL, /* merge per-server config structures */
NULL, /* table of config file commands */
foo_register_hooks /* <-- this function pointer needs to be
typedef'ed as __cdecl (register hooks)
*/
};
I'd send a patch for the Apache/APR headers myself, but I looked hard
for the typedefs for ap_hook_handler and the function pointer for the
module struct and couldn't find them in any of the .h files, sorry.
I'm hoping you can help me out with that.
--
% Andre Pang : trust.in.love.to.save
|