
Hello all, Many of Boost macro APIs PP_CAT symbols with either __LINE__ or __COUNTER__ to make them unique (MPL_STATIC_ASSERT, SCOPE_EXIT, etc). AFAIK, __LINE__ is C++03 standard while __COUNTER__ is only a MSVC extension. I think using __COUNTER__ instead of __LINE__ might allow to expand a macro multiple times on the same line... but a part from that: What's the reason for using __COUNTER__ on MSVC instead of just using __LINE__ for all compilers? Thanks a lot. --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/boost-COUNTER-vs-LINE-tp4286398p4286398.h... Sent from the Boost - Dev mailing list archive at Nabble.com.

On 11.01.2012 20:06, Andrey Semashev wrote:
As I recall, the problem is when the option for edit-and-continue is used. I had that problem with Petru Marginean's original ScopeGuard code. With the edit-and-continue option, Visual C++ really messed up the explansion of __LINE__, so that the ScopeGuard temporary names became invalid. Cheers, - Alf

Andrey Semashev-2 wrote
OK. Is there a Boost macro like this already? #include <boost/config.hpp> #ifdef BOOST_MSVC # define BOOST_LINE_COUNTER __COUNTER__ #else # define BOOST_LINE_COUNTER __LINE__ #endif Thanks. --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/boost-COUNTER-vs-LINE-tp4286398p4293111.h... Sent from the Boost - Dev mailing list archive at Nabble.com.

On Jan 13, 2012, at 2:16 PM, lcaminiti wrote:
__COUNTER__ is also available in gcc4.3 and later. http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html#Common-Prede... I don't know how precisely it matches the MSVC __COUNTER__ in various cases like pre-compiled headers and the like.
participants (6)
-
Alf P. Steinbach
-
Andrey Semashev
-
Christopher Jefferson
-
Kim Barrett
-
lcaminiti
-
Mathias Gaunard