Microsoft KB Archive/164947

= FIX: Nested Macros Cause Errors C2065 and C2064 =

Article ID: 164947

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 4.1 Subscription

-



This article was previously published under Q164947



SYMPTOMS
A nested macro may cause errors similar to the following:

error C2065: 'MACRO_B' : undeclared identifier

error C2064: term does not evaluate to a function

error C2143: syntax error : missing ';' before '}'



CAUSE
The second macro is not being expanded correctly. A preprocessed file for the following sample shows that MACRO_B is not expanded: { MACRO_B ("Hello world.\n") }; It should expand to: { { printf("Hello world.\n"); } };



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 32-bit Edition, versions 4.2.



Sample Code
/* Compile options needed: none */

#include 

#define MACRO_A(A)     { MACRO_B A } #define MACRO_B(A)     { printf(A); }

void main {         MACRO_A(("Hello world.\n")); }

Additional query words: kbVC420bug kbVC400bug

Keywords: kbbug kbfix kbcodegen kbcompiler KB164947

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.