非法使用类型作为表达式

时间:2022-09-15 19:15:36

I have the following lines in my source code which is giving the error

我的源代码中有以下行,它们给出了错误

error C2275: 'HPDF_Array' : illegal use of this type as an expression" : This is the actual code in the header file:

错误C2275:'HPDF_Array':非法使用此类型作为表达式“:这是头文件中的实际代码:

 typedef struct _HPDF_Array_Rec  *HPDF_Array;

typedef struct _HPDF_Array_Rec {
    HPDF_Obj_Header  header;
    HPDF_MMgr        mmgr;
    HPDF_Error       error;
    HPDF_List        list;
} HPDF_Array_Rec;

    HPDF_Array id;

How do I resolve this error?

我该如何解决这个错误?

2 个解决方案

#1


0  

This code works on my compiler (gcc 4.7.1), so maybe you need to show more code or information in general if you're still having trouble:

此代码适用于我的编译器(gcc 4.7.1),因此如果您仍然遇到问题,可能需要显示更多代码或信息:

// content of this struct is irrelevant, so I just made a dummy struct
struct _HPDF_Array_Rec {
    int dummy;
};


typedef struct _HPDF_Array_Rec  *HPDF_Array;
HPDF_Array id;

What the code in your question does, is define the type HPDF_Array as a pointer to the type struct _HPDF_Array_Rec and instantiate one HPDF_Array (which is a pointer to a _HDPF_Array_Rec struct) called id

您的问题中的代码所做的是将HPDF_Array类型定义为指向struct _HPDF_Array_Rec类型的指针,并实例化一个名为id的HPDF_Array(指向_HDPF_Array_Rec结构的指针)


EDIT:

The code still works fine. I googled the errorcode and got this:

代码仍然可以正常工作。我用谷歌搜索错误代码并得到了这个:

http://msdn.microsoft.com/en-us/library/76c9k4ah(v=vs.71).aspx

An expression uses the -> operator with a typedef identifier.

Check your code for that kind of error. Anywhere you're doing HPDF_Array->something instead of id->something ? :)

检查您的代码是否存在此类错误。你正在做的任何地方HPDF_Array->某事而不是id->某事? :)

#2


0  

If you have error while compiling hpdf_pdfa.c file, then move

如果编译hpdf_pdfa.c文件时出错,请移动

HPDF_Array id;

line to the beginning of the HPDF_PDFA_GenerateID(HPDF_Doc pdf) function.

行到HPDF_PDFA_GenerateID(HPDF_Doc pdf)函数的开头。

It appears that 2.2.1 branch was built as a C++ code, and the committer didn't notice the error. In the trunk branch this error is fixed.

似乎2.2.1分支是作为C ++代码构建的,并且提交者没有注意到错误。在主干分支中,此错误已得到修复。

#1


0  

This code works on my compiler (gcc 4.7.1), so maybe you need to show more code or information in general if you're still having trouble:

此代码适用于我的编译器(gcc 4.7.1),因此如果您仍然遇到问题,可能需要显示更多代码或信息:

// content of this struct is irrelevant, so I just made a dummy struct
struct _HPDF_Array_Rec {
    int dummy;
};


typedef struct _HPDF_Array_Rec  *HPDF_Array;
HPDF_Array id;

What the code in your question does, is define the type HPDF_Array as a pointer to the type struct _HPDF_Array_Rec and instantiate one HPDF_Array (which is a pointer to a _HDPF_Array_Rec struct) called id

您的问题中的代码所做的是将HPDF_Array类型定义为指向struct _HPDF_Array_Rec类型的指针,并实例化一个名为id的HPDF_Array(指向_HDPF_Array_Rec结构的指针)


EDIT:

The code still works fine. I googled the errorcode and got this:

代码仍然可以正常工作。我用谷歌搜索错误代码并得到了这个:

http://msdn.microsoft.com/en-us/library/76c9k4ah(v=vs.71).aspx

An expression uses the -> operator with a typedef identifier.

Check your code for that kind of error. Anywhere you're doing HPDF_Array->something instead of id->something ? :)

检查您的代码是否存在此类错误。你正在做的任何地方HPDF_Array->某事而不是id->某事? :)

#2


0  

If you have error while compiling hpdf_pdfa.c file, then move

如果编译hpdf_pdfa.c文件时出错,请移动

HPDF_Array id;

line to the beginning of the HPDF_PDFA_GenerateID(HPDF_Doc pdf) function.

行到HPDF_PDFA_GenerateID(HPDF_Doc pdf)函数的开头。

It appears that 2.2.1 branch was built as a C++ code, and the committer didn't notice the error. In the trunk branch this error is fixed.

似乎2.2.1分支是作为C ++代码构建的,并且提交者没有注意到错误。在主干分支中,此错误已得到修复。