开发者

Acessing structure declared from another file->Objective C

I am new to objective C.

remote.h

struct RMH_REQUEST_SESSION_MSG
{
    int  uDeviceID;
    int  uProtocolVersion;
    int  uReserved[5];
};

    @interface rem开发者_运维百科ote : NSObject {
   }
    @end




   data_derived.h

    #import "remote.h"

    @interface data_derived : data {

    @public
     RMH_REQUEST_SESSION_MSG st;

}

@end

Error:Expected specifier-qualifier-list before 'RMH_REQUEST_SESSION_MSG'

Here the structure declaration is made outside but i could not able to assign a variable

for this structure in another class that is declared in another file.I'm getting an

error.What has to be done to clear up this error.Thanks in advance.


try

struct RMH_REQUEST_SESSION_MSG st;

instead of

RMH_REQUEST_SESSION_MSG st;

structure implementation in objective C is similiar to C structures..we need struct keyword when declaring structure variables..Else you can use typedef

typedef struct {
    int data1;
    char data2;
} RMH_REQUEST_SESSION_MSG;

and later..

RMH_REQUEST_SESSION_MSG st;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜