Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with #define - expected expression before "=" token

Beginner's question: I dared to introduce constants into my little program. I first resisted, but then I thought I should give it a try... to see that it doesn't work.

Okay, this is what I have put in the very first line of my .m file:

#define kPageCurlSpeed = 2.5;

And this is what I put in my method:

[UIView setAnimationDuration:kPageCurlSpeed];

And behold... it doesn't work and I get the compiler message that "expected expression before "=" token"... I have no idea of how to translate that into English.

I thought the compiler simply replaces kPageCurlSpeed with 2.5 -- so this shouldn't cause any problems. But I guess that's just theory.

Any help would be very much appreciated.

like image 250
n.evermind Avatar asked Apr 01 '11 16:04

n.evermind


People also ask

What is a better word for problems?

Some common synonyms of problem are enigma, mystery, puzzle, and riddle. While all these words mean "something which baffles or perplexes," problem applies to a question or difficulty calling for a solution or causing concern.

What's a problem-solving skill?

Problem-solving skills are the ability to identify problems, brainstorm and analyze answers, and implement the best solutions.


1 Answers

You don't need = in an #define or the semicolon afterwards. Just use

#define kPageCurlSpeed  2.5

Read e.g. this wikipedia article on C preprocessor.

like image 172
Yuji Avatar answered Oct 01 '22 12:10

Yuji