简体   繁体   中英

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

...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.

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.

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.

Please don't summarize code. The mistakes are often in the parts that you "know* are right, and leave out of the summary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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