#define - “=”之前的预期表达式的问题令牌 [英] 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.
好吧,这是我已经放在我的.m文件的第一行:
Okay, this is what I have put in the very first line of my .m file:
#define kPageCurlSpeed = 2.5;
这是我在我的方法中:
[UIView setAnimationDuration:kPageCurlSpeed];
注意...它不工作,我得到编译器消息expected expression before =token...我不知道如何将它翻译成英语。
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.
我认为编译器只是用2.5替换kPageCurlSpeed, t造成任何问题。但我想这只是理论。
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.
推荐答案
在<$ c $中不需要 =
c> #define 或分号后面。只需使用
You don't need =
in an #define
or the semicolon afterwards. Just use
#define kPageCurlSpeed 2.5
阅读例如关于C预处理器的维基百科文章。
这篇关于#define - “=”之前的预期表达式的问题令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!