在 Apache 服务器中设置指令时出现不兼容的指针类型错误

Incompatible pointer type error while setting directives in Apache server

我正在尝试使用 'The directive handler function' 部分中的示例代码在 Apache 服务器中设置指令 http://httpd.apache.org/docs/2.4/developer/modguide.html.

这是我的代码:

static const command_rec example_directives[] =
{
    AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, ACCESS_CONF, "Enable or disable mod_privet"),
    AP_INIT_TAKE1("examplePath", example_set_path, NULL, ACCESS_CONF, "The path to whatever"),
    AP_INIT_TAKE2("exampleAction", example_set_action, NULL, ACCESS_CONF, "Special action value!"),
    { NULL }
};

Handler for directives:


/* Handler for the "exampleEnabled" directive */
const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
{
    if(!strcasecmp(arg, "on")) config.enabled = 1;
    else config.enabled = 0;
    return NULL;
}

/* Handler for the "examplePath" directive */
const char *example_set_path(cmd_parms *cmd, void *cfg, char *arg)
{
    config.path = arg;
    return NULL;
}

/* Handler for the "exampleAction" directive */
/* Let's pretend this one takes one argument (file or db), and a second (deny or allow), */
/* and we store it in a bit-wise manner. */
const char *example_set_action(cmd_parms *cmd, void *cfg, const char *arg1, const char *arg2)
{
    if(!strcasecmp(arg1, "file")) config.typeOfAction = 0x01;
    else config.typeOfAction = 0x02;

    if(!strcasecmp(arg2, "deny")) config.typeOfAction += 0x10;
    else config.typeOfAction += 0x20;
    return NULL;
}

但是,当我尝试构建时,出现以下错误:

错误:从不兼容的指针类型初始化 [-Werror] AP_INIT_TAKE1("examplePath", example_set_path, NULL, ACCESS_CONF, "The path to whatever")

我是不是错过了什么?

谢谢

example_set_path的第三个参数应该是const char *arg

#define AP_INIT_TAKE1 ( directive,  
  func,  
  mconfig,  
  where,  
  help    )     { directive, { .take1=func }, mconfig, where, TAKE1, help } 

函数定义为...

const char *(*  take1 )(cmd_parms *parms, void *mconfig, const char *w)