BUG: C1017 Occurs with /Zg and #ifLast reviewed: July 22, 1997Article ID: Q111357 |
1.00 1.50
WINDOWS
kbtool kbbuglist
The information in this article applies to:
SYMPTOMSA C1017 error is incorrectly generated when using /Zg and the preprocessor directive #if on an integer constant. For example, using #if 0 or #if 3 causes the following error:
file.c(3) : fatal error C1017: invalid integer constant expressionNote that the error also occurs when a symbol that evaluates to an integer constant is referenced in a #if directive. For example:
#define ZERO 0 #if ZERO RESOLUTIONThe following are two possible workarounds:
MORE INFORMATIONThe most common reason for using an expression that always evaluates to an integer constant is to enable conditional compilation, which is dependent on a particular symbol being used. For example, the following code prints out information only when the MYDEBUG_BUILD_OPTION symbol is defined to be equal to 1:
#include <stdio.h> #define MYDEBUG_BUILD_OPTION 1 // Use #define MYDEBUG_BUILD_OPTION 0 to do a non-debug build. void main(void) { #if MYDEBUG_BUILD_OPTION printf("We are debugging\n"); #endif printf("Hello world\n"); }By following the second workaround (listed above), this code could be rewritten to use #ifdef:
#include <stdio.h> #define MYDEBUG_BUILD_OPTION // Remove the above line to do a non-debug build, or // eliminate the define and use the /D compiler option // to define MYDEBUG_BUILD_OPTION for debug builds. void main(void) { #ifdef MYDEBUG_BUILD_OPTION printf("We are debugging\n"); #endif printf("Hello world\n"); } STATUSMicrosoft has confirmed this to be a problem in the Microsoft C/C++ compiler versions 8.0 and 8.0c for MS-DOS. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
|
Additional reference words: 1.00 1.50 8.00 8.00c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |