在Apache服务器中设置指令时出现不兼容的指针类型错误
Incompatible pointer type error while setting directives in Apache server
我正试图使用位于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;
}
然而,当我尝试构建时,我会得到以下错误:
错误:从不兼容的指针类型进行初始化[-Weror]AP_INIT_TAKE1("examplePath",example_set_path,NULL,ACCESS_CONF,"到任何东西的路径")
我是不是错过了什么?
感谢
example_set_path的第三个参数应该是const char *arg
#define AP_INIT_TAKE1 ( directive,
func,
mconfig,
where,
help ) { directive, { .take1=func }, mconfig, where, TAKE1, help }
func被定义为…
const char *(* take1 )(cmd_parms *parms, void *mconfig, const char *w)
相关文章:
- 我收到同义重复编译器错误。我应该如何修复"类型"X"的参数与类型"X"的参数不兼容?
- 字符类型转换不兼容
- Qt:如何使不兼容的发送方/接收方参数兼容?
- 视觉工作室 2017;启用 /permissive 时,类型 "const wchar_t *" 的参数与类型 "PWSTR" 的参数不兼容
- 我正在尝试将表的地址传递给要在另一个函数中使用的指针,但得到不兼容的指针类型
- OPENCL 警告:不兼容的指针类型将'float __global[16]'传递给类型为 '__global float4 的参数 *
- 如何警告 C 中 void 指针上的参数不兼容的类型
- 不断增加的指针数组 错误:赋值中的类型不兼容
- 不兼容的指针类型警告c
- C++函数指针类型与 Linux 和 VMS 上的候选指针类型不兼容
- 为什么函数指针和数据指针在 C/C++ 中不兼容
- C++指向函数作为参数的指针.数据类型不兼容
- C - 使用类型为 'int 的表达式初始化'int *'的不兼容指针类型
- 声明与(方法)指针不兼容
- 调用指向派生类成员的指针时,指向与对象类型不兼容的成员类型的指针
- 声明不兼容.(指针)
- 在vector中的vector之间移动指针会导致vector迭代器不兼容
- 与指针参数不兼容的无符号字符数组
- 模板和不透明指针是否在继承上不兼容
- 在Apache服务器中设置指令时出现不兼容的指针类型错误