<p>Consider these two function definitions:</p>

<pre><code>void foo() { }

void foo(void) { }
</code></pre>

<p>Is there any difference between these two? If not, why is the <code>void</code> argument there? Aesthetic reasons?</p>

[{'answer_id': 51041, 'author': 'Paul Tomblin', 'author_id': 3333, 'author_profile': 'https://Stackoverflow.com/users/3333', 'pm_score': 2, 'selected': False, 'text': '<p>In C, you use a void in an empty function reference so that the compiler has a prototype, and that prototype has "no arguments". In C++, you don\'t have to tell the compiler that you have a prototype because you can\'t leave out the prototype.</p>\n'}, {'answer_id': 51044, 'author': 'Kyle Cronin', 'author_id': 658, 'author_profile': 'https://Stackoverflow.com/users/658', 'pm_score': 5, 'selected': False, 'text': '<p>I realize your question pertains to C++, but when it comes to C the answer can be found in <a href="https://en.wikipedia.org/wiki/The_C_Programming_Language" rel="nofollow noreferrer">K&amp;R</a>, pages 72-73:</p>\n<blockquote>\n<p>Furthermore, if a function declaration does not include arguments, as\nin</p>\n<pre><code>double atof();\n</code></pre>\n<p>that too is taken to mean that nothing is to be assumed about the\narguments of atof; all parameter checking is turned off. This special\nmeaning of the empty argument list is intended to permit older C\nprograms to compile with new compilers. But it\'s a bad idea to use it\nwith new programs. If the function takes arguments, declare them; if\nit takes no arguments, use void.</p>\n</blockquote>\n'}, {'answer_id': 51080, 'author': 'DrPizza', 'author_id': 2131, 'author_profile': 'https://Stackoverflow.com/users/2131', 'pm_score': 9, 'selected': True, 'text': '<p>In <strong>C</strong>:  </p>\n\n<ul>\n<li><code>void foo()</code> means "a function <code>foo</code> taking an unspecified number of arguments of unspecified type"  </li>\n<li><code>void foo(void)</code> means "a function <code>foo</code> taking no arguments"</li>\n</ul>\n\n<p>In <strong>C++</strong>:  </p>\n\n<ul>\n<li><code>void foo()</code> means "a function <code>foo</code> taking no arguments"  </li>\n<li><code>void foo(void)</code> means "a function <code>foo</code> taking no arguments"</li>\n</ul>\n\n<p>By writing <code>foo(void)</code>, 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 an <code>extern "C"</code> if we\'re compiling C++).</p>\n'}, {'answer_id': 36835303, 'author': 'Ciro Santilli OurBigBook.com', 'author_id': 895245, 'author_profile': 'https://Stackoverflow.com/users/895245', 'pm_score': 3, 'selected': False, 'text': '<p><strong>C++11 N3337 standard draft</strong></p>\n<p>There is no difference.</p>\n<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf" rel="nofollow noreferrer">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf</a></p>\n<p><em>Annex C &quot;Compatibility&quot; C.1.7 Clause 8: declarators</em> says:</p>\n<blockquote>\n<p>8.3.5 Change: In C ++ , a function declared with an empty parameter list takes no arguments. In C, an empty\nparameter list means that the number and type of the function arguments are unknown.</p>\n<p>Example:</p>\n<pre class="lang-c prettyprint-override"><code>int f();\n// means int f(void) in C ++\n// int f( unknown ) in C\n</code></pre>\n<p>Rationale: This is to avoid erroneous function calls (i.e., function calls with the wrong number or type of\narguments).</p>\n<p>Effect on original feature: Change to semantics of well-defined feature. This feature was marked as “obsolescent” in C.</p>\n</blockquote>\n<p><em>8.5.3 functions</em> says:</p>\n<blockquote>\n<p>4. The parameter-declaration-clause determines the arguments that can be specified, and their processing, when\nthe function is called. [...] If the parameter-declaration-clause is empty, the function\ntakes no arguments. The parameter list (void) is equivalent to the empty parameter list.</p>\n</blockquote>\n<p><strong>C99</strong></p>\n<p>As mentioned by C++11, <code>int f()</code> specifies nothing about the arguments, and is obsolescent.</p>\n<p>It can either lead to working code or UB.</p>\n<p>I have interpreted the C99 standard in detail at: <a href="https://stackoverflow.com/a/36292431/895245">https://stackoverflow.com/a/36292431/895245</a></p>\n'}]
['https://Stackoverflow.com/questions/51032', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1597/']