Whlie reading codes of my group project, I come across many DEFINEs, and some of them seems strange. To generalize it, please look at the following 2 examples.
Example 1:
#define SNPRINTF(dst, fmt, arg...) snprintf(dst, sizeof(dst), fmt, ##arg)
what does "##" means in this circumstance? I've tried to delete both of them, and write codes like "char buf[1024]; SNPRINTF(buf,"%s,%s","abcd","efg");" which produced the same result. So "##" seems no use and no harm to me.
Example 2:
#define CLOSE(fd) do { \
if (-1 != (fd)) { \
close(fd); \
(fd) = -1; \
} \
} while (0)
Necessary to stuff the inner code to the do{}while(0) statement? what's the use?
Thanks!