3 ms·
Quick question: why does he do this? int main(int argc, char * argv[]) { (void)argc; (void)argv; I've programmed C while in school, but I don'
by slig 14y ago
Quick question: why does he do this?
int main(int argc, char * argv[]) {
(void)argc;
(void)argv;
I've programmed C while in school, but I don't remember ever seeing this and I'm not sure how to google it.
- walrus 14y agoIt stops the compiler from complaining about unused variables: http://stackoverflow.com/questions/8052091/void-cast-of-argc-and-argv http://stackoverflow.com/questions/8052091/void-cast-of-argc...
- tmhedberg 14y agoWhy would you do this instead of declaring it as `int main(void)`?
- jvranish 14y agoI use clang with a -Wall and -Wextra, which will complain about all sorts of stuff I generally want to know about, including unused variables (I think gcc does the same?). For the rare cases where I actually want to leave a variable unused I do the above to make the warning go away.
- deleted 14y ago[deleted]