BUG: C2099 Generated Initializing Struct with MacroLast reviewed: July 24, 1997Article ID: Q116170 |
The information in this article applies to:
SYMPTOMSUsing a macro to initialize a structure causes the C/C++ compiler to incorrectly generate the following error message:
error C2099: initializer is not a constant STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe sample code below can be used to reproduce this problem:
Sample Code
/* Compile options needed: none */ #include <stddef.h> #define ZIP struct zip_struct #define ZOT struct zot_struct #define TABLE struct table_struct ZIP { ZOT { int num; } m_zot; }; #define MACRO(tok) \ { (offsetof(ZIP, m_zot.tok) - offsetof(ZIP, m_zot)) / sizeof(int) } TABLE { int Offset; int ModNum; }; TABLE test[] = { { offsetof(ZIP, m_zot.num) - offsetof(ZIP, m_zot) / sizeof(int) } }; TABLE test2[] = { { MACRO(num) } }; void main(void) { } |
Additional query words: 8.00 8.00c 9.00 10.00 10.10 10.20
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |