1

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:

 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?

artyom.stv
  • 2,097
  • 1
  • 24
  • 42
Rakesh K
  • 8,237
  • 18
  • 51
  • 64

2 Answers2

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:

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


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 ? :)

Morten Jensen
  • 5,818
  • 3
  • 43
  • 55
  • I just updated my question with more code, may be this will give more clarity. Is it ok to have to typedefs for a same struct - one defined and one not? – Rakesh K Sep 27 '12 at 09:04
0

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

HPDF_Array id;

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

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.

artyom.stv
  • 2,097
  • 1
  • 24
  • 42