Microsoft KB Archive/32778

{|
 * width="100%"|

PRB: C4210 and C4001 &quot;function given file scope&quot; Warnings
'Article ID: Q32778

Creation Date: 11-JUL-1988

Revision Date: 20-OCT-1995' The information in this article applies to:

  The Microsoft C/C++ Compiler (CL.EXE), included with: - Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax - Microsoft C for OS/2, versions 6.0 and 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0 and 4.0 SYMPTOMS

The compiler generates one of the following messages when it compiles an application at warning level 4 (the compiler command line specifies the /W4 option) with language extensions enabled. Microsoft C/C++ version 8.0, which is included with Visual C++ version 1.0, generates the following message: C4210: nonstandard extension used : function given file scope Microsoft C/C++ compiler included with Visual C++, 16- and 32-bit editions, generates the following message: C4001 nonstandard extension used - 'file given file scope' CAUSE

The code attempts to declare a function with block scope, that is, inside another function. These warnings indicate that placing the function prototype in the block is an extension to ANSI standard C and the compiler processes the code as if the function was declared at file scope. RESOLUTION

To avoid this warning, modify the source code to place the function prototype outside the function. MORE INFORMATION

The following code example demonstrates this situation. Sample Code

/* Compile option needed: /W4 */ void main (void); void main (void) { void myfunc(int x); } 
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED &quot;AS IS&quot; 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." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00 1.50 2.00 4.00 6.00 6.00a 6.00ax 7.00 8.00

8.00c 9.00

KBCategory: kbtool kbfasttip kbprb

KBSubcategory: CLIss