/WX Option Causes Suppression of C4101 & C4102 Warnings

Last reviewed: July 17, 1997
Article ID: Q85875
7.00 | 1.00 1.50 1.51 MS-DOS | WINDOWS kbtool

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C/C++ for MS-DOS, versions 7.0
        - Microsoft Visual C++ for Windows, versions 1.0, 1.5, and 1.51
    

SUMMARY

The /WX switch causes the following two warnings

   warning C4102: identifier : unreferenced label
   warning C4101: identifier' : unreferenced local variable

to be suppressed after any warning occurs. To see all the warnings, the /WX switch must be omitted.

MORE INFORMATION

Normally, the compiler continues to generate errors until the end of compilation or until a fatal error occurs. Because the /WX switch causes warnings to be treated as nonfatal errors, one might expect to see all other occurrences of the C4101 and C4102 warnings. This is not the case.

NOTE: This behavior does not occur using Visual C++ 32-bit Edition.

With the following sample code, if the following command line is used

   cl /W4 /WX file.c

the compiler will only generate the following warnings:

   warning C4035: 'main' : no return value
   error C2220: warning treated as error - no object file generated

If we omit the /WX compiler option, the compiler generates the following warnings:

   warning C4035: 'main' : no return value
   warning C4102: 'Label' : unreferenced label
   warning C4101: 'b' : unreferenced local variable
   warning C4101: 'c' : unreferenced local variable

Sample Code

In the sample code below, note that by removing the /WX switch, the compiler issues all the warnings.

/* Compile options needed: /W4 /WX
*/

#include <stdio.h>

main(void) {
   int a = 1;
   int b ;
   int c ;

Label:
   printf (" a =  %d \n");
}


Additional reference words: kbinf 1.00 1.50 7.00 8.00 8.00c
KBCategory: kbtool
KBSubcategory: CLIss
Keywords : kb16bitonly


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: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.