PRB: Signed/Unsigned Mismatch Warning When Using MSCS Constants

Last reviewed: March 19, 1998
Article ID: Q182659
The information in this article applies to:
  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows NT Server Enterprise Edition version 4.0

SYMPTOMS

When building a project that uses "constants" defined for Microsoft Cluster Server, the compiler might report a signed or unsigned mismatch warning.

CAUSE

The values are defined in clusapi.h using enum instead of #define. Enum values are of type int, but the values are most often used as DWORD (unsigned long) parameters. If the high bit of the value is set, the compiler generates a warning.

RESOLUTION

The values can be cast to a DWORD before assigning them to, or using them as, a DWORD. For example:

   dwParam = (DWORD) CLUSTER_CHANGE_HANDLE_CLOSE;

STATUS

This behavior is by design.

MORE INFORMATION

When the high bit of one value of an enum is set, the compiler considers the value to be negative. When the value is assigned to an unsigned variable, the compiler warns that some information (the "negativeness") is lost in the assignment.

Enums are used instead of #define to make it easier for other languages to use the values from a generated type library.

Version           : WINDOWS:;WINNT:4.0
Platform          : WINDOWS winnt
Issue type        : kbprb
Solution Type     : kbnofix


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


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