/WX Option Causes Suppression of C4101 & C4102 Warnings

ID: Q85875

7.00 | 1.00 1.50 1.51 MS-DOS | WINDOWS kbtool

The information in this article applies to:

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

Last Reviewed: July 18, 1997