4917
5879
3万
GROAD
曲径通幽,安觅芳踪。
#define SAFE_FREE(p) do{ free(p); p = NULL; } while (0)
#define SAFE_FREE(p) free(p); p = NULL;
#include <stdio.h> #include <stdlib.h> #define SAFE_FREE(p) free(p); p = NULL; int main() { int *p = malloc (sizeof(int)); *p = 10; if (p != NULL) SAFE_FREE(p); else ; return (0); }
gcc -g do_while.c -o do_while do_while.c: In function ‘main’: do_while.c:13: error: ‘else’ without a previous ‘if’
if (p != NULL) { free(p); p = NULL; }; else ... ...
if (p != NULL) do { free(p); p = NULL) } while(0); else ... ...
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )
GMT+8, 2024-5-10 20:15 , Processed in 0.072042 second(s), 22 queries .
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.