spandana
spandana

Reputation: 755

Structure in objective c

Getting errors when declaring this structure in objective c.

struct stRs232Struct*  pStruct;
pStruct->nMessageId = (int)uMessageId;

Error:Dereferencing pointer to incomplete type

Upvotes: 0

Views: 618

Answers (2)

DarkDust
DarkDust

Reputation: 92442

The compiler is warning you that it knows there's a type, but it doesn't know how that type looks like. You most likely have a forward declaration (struct stRs232Struct;) somewhere but you have not included the complete definition (struct stRs232Struct { ... };).

Upvotes: 2

What is stRs232Struct? Is it your own structure? If yes then you actually should declare it somewhere. Something like this:

struct stRs232Struct {
    int nMessageId;
};
...
struct stRs232Struct* pStruct;
pStruct->nMessageId = (int)uMessageId;
...

If you have already declared it then you should check if the corresponding .h-file with its definition is included before usage.

Upvotes: 1

Related Questions