BUG: Expansion of __LINE__ Macro Is Incorrect When Using /ZI

ID: Q199057


The information in this article applies to:
  • Microsoft Visual C++, 32-bit Editions, version 6.0


SYMPTOMS

The results of the __LINE__ macro are incorrect when you use Debug Information for Edit and Continue (/ZI). The problem may manifest itself as compiler, linker, or run-time errors.


RESOLUTION

To work around this problem, use the Program Database option (/Zi) instead of Edit and Continue (/ZI).


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

The following sample code demonstrates the problem:


   // TEST.CPP - Compile with /GX and /Zi or /ZI.
   #include <iostream>
   using namespace std;

   #define CONCAT(s1,s2) #s1 ## #s2
   #define MSG(n) cout << CONCAT(Message at line\x20,n) << endl;

   int main()
   {
   MSG(__LINE__);
   return 0;
   } 


When compiled with the /Zi option, output is correct:

Message at line 10


When compiled with the /ZI option, output is incorrect:

Message at line (__LINE__Var+1)

Additional query words:

Keywords : kbCompiler kbVC600bug
Version : winnt:6.0
Platform : winnt
Issue type : kbbug


Last Reviewed: January 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.