Boost logo

Boost :

From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2007-12-04 03:22:00


On Dec 4, 2007 6:54 AM, Sid Sacek <ssacek_at_[hidden]> wrote:

>
> Other compilers don't have this built-in macro, but it seems to me that
> you can create something useful with compiler arguments. For
> example:
>
> g++ main.cpp -D_FILE_ORDINAL_=10000
>
> You also need these macros somewhere that use the ordinal value as
> follows:
>
> #define _COUNTER3( O, L ) O##L
> #define _COUNTER2( O, L ) _COUNTER3( O, L )
> #define _COUNTER _COUNTER2( _FILE_ORDINAL_, __LINE__ )
>
> If every compiled file gets its own large ordinal number, you should never
> have the same value for _COUNTER twice.

__LINE__ is not unique in a translation unit. For each included header, it
is restarted from 1.
So if you happen to use _COUNTER in two boost header files at the same line,
and the two headers are included by the same c++ file, you end up with
clashing counters.

Corrado


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk