@implementation classname
static const unsigned int OFFSET_STX =0;
static const unsigned int OFFSET_ETX =1;
static const unsigned int OFFSET_KTX =2;
static const unsigned int OFFSET_MTX =4;
static const unsigned int OFFSET_LTX =5;
static const char STX =0x05;
static const char ETX =0x09;
@end
Error:
expected '=', ',', ';', 'asm' or '__attribute__' before 'sizeof'
How do i declare these static variables inside the class.
Do i 开发者_Python百科need to declare
+(int)OFFSET_ETX
{
return OFFSET_ETX=0;
}
and call through [classname OFFSET_ETX]; for every static variables. I am having more than 10 static variables to be assigned in my program.
You cannot put a static variable inside a class interface in Objective C. In Objective C, static
has the same meaning as it does in C. Do this instead:
enum {
OFFSET_STX = 0,
OFFSET_ETX = 1,
OFFSET_KTX = 2,
OFFSET_MTX = 3,
OFFSET_LTX = 4
};
@implementation classname
...
@end
精彩评论