Microsoft KB Archive/35471: Difference between revisions
m (Text replacement - "<" to "<") |
m (X010 moved page Microsoft KB Archive/Q35471 to Microsoft KB Archive/35471 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/") |
||
(One intermediate revision by the same user not shown) | |||
Line 15: | Line 15: | ||
The following source code demonstrates the problem: | The following source code demonstrates the problem: | ||
#include <stdio.h | #include <stdio.h> | ||
#define Right_Way 1 #define Wrong_Way +2 | #define Right_Way 1 #define Wrong_Way +2 |
Latest revision as of 19:21, 12 August 2020
Unary Plus Operator Not Valid for Case Expression PSS ID Number: Q35471 Article last modified on 10-12-1988 PSS database name: S_QuickC
1.01
MS-DOS
Summary:
The unary plus operator causes the error message C2051 “Case expression not constant.” The expression works correctly with C Version 5.10. The unary plus operator was not expected in C compilers prior to the ANSI standard.
Microsoft has confirmed this to be a problem in Version 1.01. We are researching this problem and will post new information as it becomes available.
More Information:
The following source code demonstrates the problem:
- include <stdio.h>
- define Right_Way 1 #define Wrong_Way +2
void main() { int x; for (x= 1; x<3; x++) switch (x) { case Right_Way: puts(“This works”); break; case Wrong_Way: puts(“Get compile error”); break; default: puts(“Unknown”); } }
Copyright Microsoft Corporation 1988.