Boost logo

Boost Users :

From: Stewart Tootill (stewart.tootill_at_[hidden])
Date: 2006-03-08 04:17:01


There is a known bug with MSVC71 where if you use __LINE__ too much (not sure what the limits are or under what circumstances though), you get a "Fatal Error: Out of Keys" or something similar. Instead of this, for generating unique variable names etc I have seen the __COUNTER__ macro used instead, which provides similar functionality, but doesn't seem to suffer from this issue.

Yours,

Stewart

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]]On Behalf Of Wu Yinghui,
Freddie
Sent: 08 March 2006 09:00
To: boost-users_at_[hidden]
Subject: [Boost-users] 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 <boost/preprocessor/cat.hpp>
#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.

Does anyone on the list has more insight on this issue?

Or, what're the common ways to generate an unique identifier
automatically within certain scope?

Cheers,

Freddie

-- 
Wu Yinghui, Freddie
Research & Development
Software Engineer
Volume Interactions Pte Ltd
1 Kim Seng Promenade, #12-01
Great World City East Tower
Singapore 237994
Tel:   +65 62226962 (Ext 216)
Fax:   +65 62226215
Email: yhwu_at_[hidden]
URL:   http://www.volumeinteractions.com
Important:  This message is intended for the recipient(s) addressed 
above.  It contains privileged and confidential information.  If you are 
not the intended recipient, please notify the sender immediately by 
replying to this message and then delete it from your system.  You must 
not read, copy, use, or disseminate this communication in any form. 
Thank you.
________________________________________________________________________
This e-mail has been scanned for viruses by MessageLabs.
________________________________________________________________________
This e-mail has been scanned for viruses by MessageLabs.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net