C ++未声明的变量

时间:2014-11-12 00:03:10

标签: c++

我在项目中使用的文件有很多这种风格的声明:

static VALUE do_checksum(int, VALUE*, uLong (*)(uLong, const Bytef*, uInt));
...
static VALUE
 do_checksum(argc, argv, func)
     int argc;
     VALUE *argv;
     uLong (*func)(uLong, const Bytef*, uInt);
 {
    ...
 }

虽然我自己从未以这种方式编写代码,但我确信它是正确的。但是,我的编译器返回

error: 'VALUE do_checksum' redeclared as different kind of symbol
error: 'argc' was not declared in this scope

这里有什么问题?

Windows 7

Code :: Blocks w / MinGW

1 个答案:

答案 0 :(得分:0)

你有一些旧式的C参数列表声明。

以下是一个示例修复:

static VALUE do_checksum(
    int argc,
    VALUE *argv,
    uLong (*func)(uLong, const Bytef*, uInt)
    )
{
    ...
}

更好的修复方法是为func创建类型别名,如下所示:

using func_ptr_type = uLong (*)(uLong, const Bytef*, uInt);