Microsoft KB Archive/51198

= INFO: Formal Parameters Default to Type int =

Article ID: 51198

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft C Professional Development System 6.0
 * Microsoft C Professional Development System 6.0a
 * Microsoft C Professional Development System 6.0a
 * Microsoft C Professional Development System 6.0
 * Microsoft C Professional Development System 6.0a
 * Microsoft C/C++ Professional Development System 7.0
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 5.0 Standard Edition

-



This article was previously published under Q51198





SUMMARY
In Microsoft C, a function declaration such as the following does not generate a compiler error even though the variable &quot;voida&quot; is not referenced: void main (voida) {  } NOTE: This is true only for the C compiler, not the C++ compiler. The C and QuickC compilers do not generate an error because the variable &quot;voida&quot; defaults to a variable of type int. The compilers understand the above function definition because they recognize the &quot;old style&quot; of ANSI C declarations as well as the new. In general, the equivalents of the above code are as follows:   Old Style                           New Style -                          -

void function (voida)              void function (int voida) int voida; <- default if missing   { {                                  }   } Please refer to &quot;The C Programming Language&quot; by Brian Kernighan and Dennis Ritchie for a discussion on differences between old and new style with regards to function definition.

Additional query words: 8.00 8.00c 9.00

Keywords: kbcompiler KB51198

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.