Consider these two function definitions:
void foo() { } void foo(void) { }
Is there any difference between these two? If not, why is the void argument there? Aesthetic reasons?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Historical note: this answer applies to C17 and older editions. C23 and later editions treat
void foo()differently.In C:
void foo()means "a functionfootaking an unspecified number of arguments of unspecified type"void foo(void)means "a functionfootaking no arguments"In C++:
void foo()means "a functionfootaking no arguments"void foo(void)means "a functionfootaking no arguments"By writing
foo(void), therefore, we achieve the same interpretation across both languages and make our headers multilingual (though we usually need to do some more things to the headers to make them truly cross-language; namely, wrap them in anextern "C"if we’re compiling C++).