Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++未声明变量_C++ - Fatal编程技术网

C++未声明变量

C++未声明变量,c++,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); { ... } 虽然我自己从未以

我在项目中使用的文件有许多这种样式的声明:

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
这里怎么了

视窗7


代码::块w/MinGW

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

下面是一个示例修复:

static VALUE do_checksum(
    int argc,
    VALUE *argv,
    uLong (*func)(uLong, const Bytef*, uInt)
    )
{
    ...
}
更好的修复方法是为func创建一个类型别名,如下所示:


C++不支持C旧风格的参数声明。@ JONAANTEPOTER:那些是旧的C参数声明。现代C仍然允许他们,但他们已经正式过时,从1989。讨论一个讨论。所以我应该通过并重写所有的声明?如果你打算使用这一点与C++编译器,你没有选择,然后是。保留前向声明,只需更改参数列表;完全是吗?@chrisvj,不,看起来更接近。您需要将参数声明移到中,并用分号替换逗号。据我所知,您使用的代码需要它是一个前向声明,省略号表示它后面的内容。
using func_ptr_type = uLong (*)(uLong, const Bytef*, uInt);