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

Last reviewed: September 4, 1997
Article ID: Q79845

The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows versions 1.0, 1.5 - Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, 2.1, 4.0, 5.0

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:

   ARTICLE-ID: Q94579
   TITLE     : Creating a Function Pointer to a C++ Member Function
Keywords          : CPPLngIss
Version           : MS-DOS:7.0; WINDOWS:1.0,1.5; WINDOWS  NT:1.0,2.0,2.1,4.0,5.0
Platform          : MS-DOS NT WINDOWS
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 4, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.