错误 C2275 RHandle:非法使用此类型作为表达式
error C2275 RHandle: illegal use of this type as an expression
我收到错误:
C2275 RHandle:非法使用此类型作为表达式
。当我编译这个时:
int main(){
int i,j;
float** tree;
tree = (float**)malloc(15 * sizeof(float*));
for( i = 0; i < 15; i++)
tree[i] = (float*)malloc(2 * sizeof(float));
for(i = 0; i < 15; i++)
for( j = 0; j < 2; j++)
tree[i][j] = 2;
RHandle h = create_reprVectorsTree(tree, 8, 2); // error at this line
// ...
}
我的界面看起来像这样:
struct reprVectorsTree;
#ifdef __cplusplus
extern "C" {
#endif
typedef struct reprVectorsTree * RHandle;
RHandle create_reprVectorsTree(float **, int , int );
void free_reprVectorsTree(RHandle);
float* work_decode(RHandle , int *, int);
#ifdef __cplusplus
}
#endif
我遵循了这个问题中的示例。
我正在Visual Studio 2008上编译。
问题出在哪里?
只是一个猜测,但如果它被编译为 C89,你不能像这样在作用域中间声明一个变量。
int main(){
int i,j;
float** tree;
RHandle h;
tree = (float**)malloc(15 * sizeof(float*));
for( i = 0; i < 15; i++)
tree[i] = (float*)malloc(2 * sizeof(float));
for(i = 0; i < 15; i++)
for( j = 0; j < 2; j++)
tree[i][j] = 2;
h = create_reprVectorsTree(tree, 8, 2);
你是否开始你的代码
#include "my_header.h"
当然,使用您的接口文件的任何名称?如前所述,编译器无法知道RHandle
的含义。
请不要总结代码。错误往往出现在你"知道*是正确的部分,而忽略在摘要之外。
相关文章:
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 如何计算具有指定类型的表达式的相对精度和绝对精度
- 来自 DLL 的函数调用 [表观调用的括号前面的表达式必须具有(指向-)函数类型]
- 表达式 SFINAE:如何根据类型是否包含具有一个或多个参数的函数来选择模板版本
- 有没有办法一次声明相同类型的多个对象,并通过一个表达式立即使用相同的右值初始化它们?
- 表观调用前面的表达式必须具有指向 func 类型的指针
- 数组类型 int[n][n] 不可赋值,因为表达式必须具有常量值
- 正则表达式以匹配数字的重复模式,后跟任何类型的分隔符?
- C++ 编译错误:意外的类型名称"字符串":预期的表达式
- 表达式必须具有类类型 vs.
- 错误:表达式必须具有算术、无作用域枚举或带有运算符重载的指针类型
- 非类类型表达式的静态类型与动态类型之间的差异
- 如何确定涉及 C++ 中除法的算术表达式的数据类型
- 结构化绑定初始值设定项表单 { 赋值表达式 } 对于 clang 上的数组类型失败
- 下标需要数组或指针类型表达式必须具有指针对象类型
- 带有数组类型表达式的错误分配
- 表示函数参数的元组的类型表达式
- 如何确定撤销类型表达式的更大类型
- c++ 11中有新的函数类型表达式格式吗?