`
yaojingguo
  • 浏览: 208010 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

C switch statement without braces

 
阅读更多

A example is static_assert.

 

 

#include <stdio.h>

#define static_assert(x)	switch (x) case 0: case (x):

int main(int argc, const char *argv[]) {

	static_assert(1 == 1);
	static_assert(1 == 2); // compile error

	int i = 10;
	switch (i) 
		printf("go\n");
}
  

Refer to http://stackoverflow.com/questions/8118009/is-there-a-useful-case-using-a-switch-statement-without-braces.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics