While trying to write an Apache2 module in C++, I found that in the command table, AP_INIT_TAKE1 has to be used like this:
AP_INIT_TAKE1( "Directive", (cmd_func) drctv_handler, NULL, OR_ALL, "help string")
rather than just this:
AP_INIT_TAKE1( "Directive", drctv_handler, NULL, OR_ALL, "help string")
The compiler I'm using (MSVC++ 6.0) does not support "designated initializers". Hence
the compiler expects the function drctv_handler to have a signature of
"const char *(*cmd_func) ();" whereas it actually has a signature of
"const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);".
The situation can be easily solved (worked around?) by changing the definition of
AP_INIT_TAKE1 (and its friends) in http_config.h to:
# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
{ directive, (cmd_func) func, mconfig, where, TAKE1, help }rather than just:
# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE1, help }The attached patch (on 2.0.47) adds this cast into all the AP_* init #defines when
the compiler does not have designated initializers.
Please consider this patch for inclusion if you think it is useful.
Regards, -Mahadevan.
--- http_config-old.h Sat Mar 08 16:27:16 2003
+++ http_config.h Wed Jul 23 16:33:30 2003
@@ -194,29 +194,29 @@
# define AP_FLAG func
# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, RAW_ARGS, help }
+ { directive, (cmd_func) func, mconfig, where, RAW_ARGS, help }
# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, RAW_ARGS, help }
+ { directive, (cmd_func) func, mconfig, where, RAW_ARGS, help }
# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE1, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE1, help }
# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, ITERATE, help }
+ { directive, (cmd_func) func, mconfig, where, ITERATE, help }
# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE2, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE2, help }
# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE12, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE12, help }
# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, ITERATE2, help }
+ { directive, (cmd_func) func, mconfig, where, ITERATE2, help }
# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE13, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE13, help }
# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE23, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE23, help }
# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE123, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE123, help }
# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, TAKE3, help }
+ { directive, (cmd_func) func, mconfig, where, TAKE3, help }
# define AP_INIT_FLAG(directive, func, mconfig, where, help) \
- { directive, func, mconfig, where, FLAG, help }
+ { directive, (cmd_func) func, mconfig, where, FLAG, help }
#endif /* AP_HAVE_DESIGNATED_INITIALIZER */
