C++未声明的变量
C++ undeclared variables
我在项目中使用的一个文件有很多这样的声明:
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
代码::块w/MinGW
您有一些旧式的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);
相关文章:
- 对类 (C++) 中的私有变量使用未声明的标识符
- 未声明的标识符错误,但变量定义正确 (?)
- Tictactoe 游戏变量未在作用域中声明
- 变量未在此范围内声明 数组线性搜索
- 奇怪的未声明变量编译器错误
- 为什么我可以在 C++ 的可变 lambda 中捕获未声明的变量
- 运行时错误,使用未声明的变量,C++
- 变量未在示波器/设置器中声明
- 在此范围C 中未声明字符串和char变量
- 在标头中声明时,变量未在范围内声明
- 错误:非静态数据成员的使用无效,在此范围内未声明变量
- "变量"未在此范围内声明
- 创建二次公式求解器-范围中未声明的变量
- 错误:变量未在此范围内声明
- 在Visual C++中,未声明的变量未标记为错误
- 错误:变量未在此范围 C++ 中声明
- 动态变量上的c++MACRO未声明标识符
- C++向量练习未声明的变量
- C++函数不是具有shared_ptr的类的成员,或者为什么我的变量未声明
- C++随机数猜测游戏-变量未声明错误