spandana
spandana

Reputation: 755

Error:expected expression before '=' token

I am getting an error as expected expression before '=' token.

#define RMH_MAX_UNENCODED_LENGTH= (RMH_MESSAGE_MAX_SIZE - RMH_ENCODED_MSG_OVERHEAD); // RMH_MAX_UNENCODED_LENGTH =4064

#define RMH_MAX_ENCODED_LENGTH = (3*sizeof(RMH_MAX_UNENCODED_LENGTH) / 4);//RMH_MAX_ENCODED_LENGTH =4;

int k = RMH_MAX_UNENCODED_LENGTH; //Error:expected expression before '=' token
NSLog(@"f:%d",k);

Upvotes: 2

Views: 7449

Answers (2)

John M
John M

Reputation: 13229

You don't want an "=" or a ";" in those #define statements. The syntax is...

#define symbol value

It's a good idea to put parentheses as you've done.

This is just plain C, no "Ojbective" stuff here. You might want to pick up a book on C to learn things like this.

Upvotes: 4

Mat
Mat

Reputation: 206765

Your syntax is wrong. Use:

#define RMH_MAX_UNENCODED_LENGTH (RMH_MESSAGE_MAX_SIZE - RMH_ENCODED_MSG_OVERHEAD)

Note: no =, no ;, no comment after it.

defines are "simply" pure text substitutions.

Upvotes: 6

Related Questions