Boost.Preprocessor with __LINE__ in MSVC71
Hi all,
I'm observing an interesting problem on MSVC71 regarding the use of
__LINE__ with Boost.Preprocessor.
The code looks like this
==== snip ====
#include
-----Original Message----- [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Wu Yinghui, Freddie
Hi all,
I'm observing an interesting problem on MSVC71 regarding the use of __LINE__ with Boost.Preprocessor.
The code looks like this ==== snip ==== #include
#define UNIQUE_ID BOOST_PP_CAT(id, __LINE__) #define UNIQUE_ID2 BOOST_PP_CAT(id, _MSC_VER) int main() { int UNIQUE_ID2 = 321; int UNIQUE_ID = 123; bool UNIQUE_ID = false; } ==== snip ==== The compiler works fine with UNIQUE_ID2, but not UNIQUE_ID. The only different in them is only the use of __LINE__ instead of _MSC_VER.
What is going wrong? I tried it on VC7, VC7.1, and VC8, and it appeared to work correctly on all three versions of the compiler.
Does anyone on the list has more insight on this issue?
I've seen strange problems related to __LINE__ on VC before, but I can't remember off the top of my head what the issue was. (Thinking...) It has something to do with the generation of debug information. Okay, yes, I see the error that you are getting now. It only happens in during a debug build. This is just one of the *many* ways in which VC's preprocessor is wacky. It suffices to say it isn't even in the ballpark of implementing the phases of translation correctly.
Or, what're the common ways to generate an unique identifier automatically within certain scope?
What do you mean by "certain scope"? Or, more precisely, given a finite scope such as that defined by a function, why do you need unique identifiers? Most of the time when people want unique identifiers, they want an identifier that is unique across an entire program or, at minimum, inside a translation unit. Regards, Paul Mensonides
Dnia środa, 8 marca 2006 10:31, Paul Mensonides napisał:
Does anyone on the list has more insight on this issue?
I've seen strange problems related to __LINE__ on VC before, but I can't remember off the top of my head what the issue was. (Thinking...) It has something to do with the generation of debug information. Okay, yes, I see the error that you are getting now. It only happens in during a debug build.
the __line__ is a *variable* in default m$ debug format, so change DebugInformationFormat="4" -> "3" in *.vcproj or select appriopriate option in project gui. -- to_be || !to_be == 1, to_be | ~to_be == -1
participants (3)
-
Paul Mensonides
-
Paweł Sikora
-
Wu Yinghui, Freddie