I get the error:
我得到了错误:
C2275 RHandle: illegal use of this type as an expression
C2275 RHandle:非法使用此类型作为表达式
...when I compile this:
…当我编译:
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
// ...
}
My interface looks like this:
我的界面是这样的:
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
I followed the example from this question.
我从这个问题中引用了这个例子。
I am compiling on Visual Studio 2008.
我正在Visual Studio 2008上编辑。
What is the problem?
这个问题是什么?
2 个解决方案
#1
3
Just a guess, but if this is being compiled as C89 you can't have a variable declared in the middle of the scope like that.
只是一个猜测,但是如果这个被编译为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);
#2
0
Did you start your code with
你开始写代码了吗?
#include "my_header.h"
using, of course, whatever name your interface file has? As written, the compiler doesn't have any way to know what RHandle
means.
使用,当然,你的接口文件有什么名字?正如所写的,编译器无法知道RHandle是什么意思。
Please don't summarize code. The mistakes are often in the parts that you "know* are right, and leave out of the summary.
请不要总结代码。错误经常出现在你“知道*是正确的”的部分,而忽略了总结。
#1
3
Just a guess, but if this is being compiled as C89 you can't have a variable declared in the middle of the scope like that.
只是一个猜测,但是如果这个被编译为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);
#2
0
Did you start your code with
你开始写代码了吗?
#include "my_header.h"
using, of course, whatever name your interface file has? As written, the compiler doesn't have any way to know what RHandle
means.
使用,当然,你的接口文件有什么名字?正如所写的,编译器无法知道RHandle是什么意思。
Please don't summarize code. The mistakes are often in the parts that you "know* are right, and leave out of the summary.
请不要总结代码。错误经常出现在你“知道*是正确的”的部分,而忽略了总结。