KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q42601: CodeView: Watchpoints and Tracepoints with Enumerated Types

Article: Q42601
Product(s): See article
Version(s): 2.20   | 2.20
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | s_c | mspl13_basic
Last Modified: 28-MAR-1989

CodeView will not display the members of an enumerated type as they
are declared in a C program. Only the integer representations of these
types of variables can be shown. The following is an example:

/*  Example enumerated type.
 */

enum e_type
{
    var1,
    var2,
    var3
};

enum e_type foo = var1;

CodeView will not display "var1", "var2", or "var3" when watching a
variable of type e_type, such as foo. CodeView will instead show the
integer values of the variable: 0, 1, and 2, respectively. In order to
watch the variable foo, you must explicitly display its value as an
integer. The following command will add the proper watch:

    w? foo,d

To set a watchpoint or a tracepoint on the same variable, further type
casts must be made. These lines will produce watchpoints and
tracepoints on foo, as follows:

    wp? *(int *)&foo == 1
    tp? *(int *)&foo

Trying to set a watchpoint without the proper type cast will result in
the following error:

    Operand types incorrect for this operation

Setting a tracepoint on foo without this type cast will set the
tracepoint but will only show "?CANNOT DISPLAY" in the watch window.
Going through the right steps will display the current integer value
of the variable, as it should.

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.

Copyright Microsoft Corporation 1986-2002.