Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-04-02 18:02:30


Brad Spencer <spencer_at_[hidden]> writes:

> In iterator/iterator_facade.hpp, there are a lot of template arguments
> that have names like "R1" and "D2". Unfortunately, these "all caps"
> tokens are fodder for collisions with macros. On i386-pc-solaris2.8,
> for some reason, "R1" is defined to be "9" (it's some kind of register
> identification macro)

In what header is it defined? Or does it come from the compiler?

> and so instead of:
>
> template < . . . , class R1, . . . >
>
> we get
>
> template < . . . , class 9, . . . >
>
> which, of course, doesn't work :)
>
> I've attached a patch against 1.31.0 (the trunk for this file) to fix
> this one file by adding "_type" to the end of all such all-caps names.
> I have not tested it very well.
>
> Perhaps there should be a policy to avoid names that are likely to
> collide with system macros?

There is such a(n informal) policy. Macros with a single capital
letter are traditionally used for template parameters, and not
normally used by system headers.

> Just using mixed case (or lower case) is
> probably enough.

I'm not sure what we should do about this. Adopting that policy
would require changes to nearly every single Boost header.

> Thanks for the great software!

You're welcome!

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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