后缀允许表达式? [英] Suffix allowed on expressions?
问题描述
嗨!
表达式是否允许使用后缀?
例如,允许以下内容:
>
#define SECONDS_PER_YEAR(60 * 60 * 365)UL
我在 http://www.embedded.com/2000/0005/0005feat2.htm
,
但是,在使用这个宏时(或者只是
表达式a =(60 * 60 * 365)UL;),我无法编译。
标准中的哪个位置表示允许/不允许?
听到是否有任何内容也会很有趣测试中的其他问题和答案中的错误。
BRs!
1月2日19:07,dspfun< dsp ... @ hotmail.comwrote:
嗨!
表达式是否允许使用后缀?
例如,允许以下内容:
#define SECONDS_PER_YEAR(60 * 60 * 365)UL
它应该是:
#define SECONDS_PER_YEAR(60 * 60 * 24 * 365)UL
>
我发现这是在C测试中,http://www.embedded.com/2000/0005/0005feat2.htm
,
然而,我无法在使用时进行编译宏(或只是
表达式a =(60 * 60 * 365)UL;)。
它应该是:
(或只是表达式声明a =(60 * 60 * 24 * 365)UL; ;)
dspfun< ds **** @ hotmail.comwrites:
表达式是否允许使用后缀?
否。你所谈论的后缀只允许在
整数和浮点常数上使用。
例如,允许以下内容:
#define SECONDS_PER_YEAR(60 * 60 * 365)UL
编号为了获得明显的预期效果,你可以写上
#define SECONDS_PER_YEAR(60UL * 60 * 365)
或
#define SECONDS_PER_YEAR(unsigned long int)(60 * 60 * 365)
-
所有代码都应该为了教学目的而刻意写。
如果你的代码不可读,它还没有完成。
- 理查德希思菲尔德
Ben Pfaff< bl*@cs.stanford.eduwrites:
为了得到明显的效果,你可以写
#define SECONDS_PER_YEAR(60UL * 60 * 365)
或
#define SECONDS_PER_YEAR(unsigned long int)(60 * 60 * 365)
哦,为了得到明显的预期价值,你需要
乘以24的额外因子。
-
char a [] =" \ n .CJacehknorstu" ;; int putchar(int); int main (void){unsigned long b []
= {0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},* p
= b,i = 24; for(; p + =!* p; * p / = 4)switch(0 [p]& 3)case 0:{return 0; for(p - ; i - ; i - )case +
2:{i ++; if(i)break; else default:continue; if(0)case 1:putchar(a [i& 15]); break;}}}
Hi!
Are suffixes allowed on expressions?
For example, is the following allowed:
#define SECONDS_PER_YEAR (60 * 60 * 365) UL
I found this in a C test at http://www.embedded.com/2000/0005/0005feat2.htm
,
however, I am not able to compile when using this macro (or just the
expression "a = (60 * 60 * 365) UL;").
Where in the standard does it say that it is allowed/not allowed?
It would also be interesting to hear if there are any faults in the
other questions and answers in the test.
BRs!
On 2 Jan, 19:07, dspfun <dsp...@hotmail.comwrote:Hi!
Are suffixes allowed on expressions?
For example, is the following allowed:
#define SECONDS_PER_YEAR (60 * 60 * 365) ULIt should be:
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365) UL
>
I found this in a C test athttp://www.embedded.com/2000/0005/0005feat2.htm
,
however, I am not able to compile when using this macro (or just the
expression "a = (60 * 60 * 365) UL;").It should be:
(or just the expression statement "a = (60 * 60 * 24 * 365) UL;")
dspfun <ds****@hotmail.comwrites:
Are suffixes allowed on expressions?No. The suffixes that you are talking about are allowed only on
integer and floating-point constants.
For example, is the following allowed:
#define SECONDS_PER_YEAR (60 * 60 * 365) ULNo. To get the apparently intended effect, you can write
#define SECONDS_PER_YEAR (60UL * 60 * 365)
or
#define SECONDS_PER_YEAR (unsigned long int) (60 * 60 * 365)
--
"All code should be deliberately written for the purposes of instruction.
If your code isn''t readable, it isn''t finished yet."
--Richard Heathfield
Ben Pfaff <bl*@cs.stanford.eduwrites:
To get the apparently intended effect, you can write
#define SECONDS_PER_YEAR (60UL * 60 * 365)
or
#define SECONDS_PER_YEAR (unsigned long int) (60 * 60 * 365)Oh, and to get the apparently intended value, you need to
multiply by an additional factor of 24.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
这篇关于后缀允许表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!