Article ID: 79845 - Last Review: December 11, 2003 - Revision: 3.0

INFO: Old Style (K&R) Declarations Are Not Supported in C++

This article was previously published under Q79845
Expand all | Collapse all

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  (http://support.microsoft.com/kb/94579/EN-US/ ) Creating a Function Pointer to a C++ Member Function

APPLIES TO
  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 1.5 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 2.1
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 5.0 Standard Edition
Keywords: 
kbinfo kblangcpp KB79845
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations