简体   繁体   English

错误C2275 RHandle:非法使用此类型作为表达式

[英]error C2275 RHandle: illegal use of this type as an expression

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? 问题是什么?

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);

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. 错误通常出现在你“知道*是正确的部分,而不在摘要中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM