This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
c-brainteasers [2012/11/30 07:58] joshuawise |
c-brainteasers [2013/10/11 00:19] joshuawise |
||
---|---|---|---|
Line 38: | Line 38: | ||
* //(taken from elsewhere on the Web)// Without running it, what is the output of the following program? \\ '' | * //(taken from elsewhere on the Web)// Without running it, what is the output of the following program? \\ '' | ||
* It is not machine-specific. | * It is not machine-specific. | ||
+ | * A common idiom in C is '' | ||
+ | * More concretely: it is easy to write a static assert macro that fails to compile if a given expression is either a) false, or b) not compile-time constant. | ||
+ | * Here are some test cases, if you care: < | ||
+ | ASSERT_CHECKER(time()); | ||
+ | ASSERT_CHECKER(0); | ||
+ | ASSERT_CHECKER(" | ||
+ | ASSERT_CHECKER(!" | ||
+ | ASSERT_CHECKER(" | ||
+ | ASSERT_CHECKER(2 + 2);</ | ||
+ | * // | ||
I've enabled comments below, but please don't post spoilers. | I've enabled comments below, but please don't post spoilers. | ||
~~DISQUS~~ | ~~DISQUS~~ |