ID: Q111357
1.00 1.50 WINDOWS kbtool kbbuglist
The information in this article applies to:
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
A 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 expression
Note 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
The following are two possible workarounds:
-or-
The 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");
}
Microsoft 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 KBCategory: kbtool kbbuglist KBSubcategory: CLIss Keywords : kb16bitonly
Last Reviewed: July 23, 1997