INFO: Old Style (K&R) Declarations Are Not Supported in C++ (79845)
The information in this article applies to:
- 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 2.1
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 5.0
This article was previously published under Q79845 SUMMARY
The Microsoft C/C++ Compiler versions 7.0 and later do not support Old
Style function declarations in C++ files. Old Style declarations are still
supported in C files.
Old Style declarations, sometimes called K&R declarations, are declarations
in which there are no parameters listed inside the parentheses. For
example:
void KRfunc(); /* declaration */
void KRfunc(a, b) /* definition */
int a;
char b;
{ }
C++ requires ANSI-style function prototypes (or declarations), which list
the type of each parameter accepted by the function, as shown here:
void ANSIfunc(int a, char b);
This type of declaration is required because in C++ each function has a
signature. The signature consists of the name of the function and the types
of the parameters it accepts. The compiler cannot construct the signature
of a function from the K&R declaration.
REFERENCES
For more information about parameter lists in function declarations and how
these are handled by C and C++, please see the following article in the
Microsoft Knowledge Base:
94579 Creating a Function Pointer to a C++ Member Function
Modification Type: | Major | Last Reviewed: | 12/11/2003 |
---|
Keywords: | kbinfo kbLangCPP KB79845 |
---|
|