INFO: Formal Parameters Default to Type int (51198)
The information in this article applies to:
- Microsoft C for MS-DOS 6.0
- Microsoft C for MS-DOS 6.0a
- Microsoft C for MS-DOS 6.0ax
- Microsoft C for OS/2 6.0
- Microsoft C for OS/2 6.0a
- Microsoft C/C++ for MS-DOS 7.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 5.0
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 "voida" 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 "voida" defaults to a variable of type int. The compilers
understand the above function definition because they recognize the
"old style" 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 "The C Programming Language" by Brian Kernighan and
Dennis Ritchie for a discussion on differences between old and new
style with regards to function definition.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbCompiler KB51198 kbAudDeveloper |
---|
|