【发布时间】:2010-10-24 10:37:46
【问题描述】:
以下是我的代码
/* Initialise default without options input. */
options -> processHiddens = false;
options -> timeResolution = DEFAULT_MOD_TIMES;
options -> performSync = true;
options -> recursive = false;
options -> print = false;
options -> updateStatus = true;
options -> verbose = false;
options -> programname = malloc(BUFSIZ);
options -> programname = argv[0];
while ((opt = getopt(argc, argv, OPTLIST)) != -1)
{
switch (opt)
{
case 'a':
!(options -> processHiddens);
case 'm':
options -> timeResolution = atoi(optarg);
case 'n':
!(options -> performSync);
case 'p':
!(options -> print);
case 'r':
!(options -> recursive);
case 'u':
!(options -> updateStatus);
case 'v':
!(options -> verbose);
default:
argc = -1;
}
}
我要做的是在每次输入选项时翻转布尔语句,因此执行类似
!(options -> processHiddens);
而不仅仅是
options -> processHiddens = true;
但是我在编译时收到以下警告:
mysync.c: In function ‘main’:
mysync.c:32: warning: statement with no effect
mysync.c:36: warning: statement with no effect
mysync.c:38: warning: statement with no effect
mysync.c:40: warning: statement with no effect
mysync.c:42: warning: statement with no effect
mysync.c:44: warning: statement with no effect
【问题讨论】:
-
请在您的案例之间使用
break;! -
哈哈,很好,完全忘记了。
标签: c structure compiler-warnings