Reputation: 1733
I am developing a command line app which uses obj-c and c files together. In my obj-c file (say x.m), I use a struct which uses an interface and the interface uses a struct. This is easily handled in C++ with forward declarations but I need obj-c in my app.
I was wondering if someone can please shed some light on what I doing wrong.
Appreciate any help and thanks in advance.
typedef struct mystruct_s
{
...
....
} mystruct;
struct abc ;
@interface abcDelegate:NSObject {
@public
struct abc *abc;
}
@end
struct abc
{
mystruct b
abcDelegate *abcdelegate;
};
I get the following error error:
expected specifier-qualifier-list before ‘mystruct’
Upvotes: 0
Views: 105
Reputation: 24846
You've forgot ;
should be
struct abc
{
mystruct b;
abcDelegate *abcdelegate;
};
If using .m file you must use c-style structs. such as
typedef struct mystruct_
{
...
} mystruct;
or
struct abc
{
struct mystruct b;
abcDelegate *abcdelegate;
};
If you want structs just like in c++ change your file extension to .mm to support c++
Upvotes: 1
Reputation: 49335
Almost there. Change the code to look like this:
struct abc
{
mystruct b;
abcDelegate *abcdelegate;
};
@interface abcDelegate:NSObject {
@public
struct abc *abc;
}
@end
Upvotes: 0