我試圖在 http://httpd.apache.org/docs/2.4/developer/modguide.html使用示例代碼中的示例代碼在Apache服務器中設置僞指令。在Apache服務器中設置僞指令時不兼容的指針類型錯誤
這裏是我的代碼:
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,「任何路徑」)
我錯過了什麼嗎?
感謝
誰偷走了你的'.c'文件? :-) –
它是'C'代碼還是'C++'?如果'C++',嘗試添加轉換到'const char *',如果'C',則使用'C'編譯器。 –
你是否包含http_config.h? – Les