[Patch] iterator/iterator_facade.hpp collides with macros on i386-pc-solaris2.8

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) 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? Just using mixed case (or lower case) is probably enough. Thanks for the great software! -- ------------------------------------------------------------------ Brad Spencer - spencer@infointeractive.com - "It's quite nice..." Systems Architect | InfoInterActive Corp. | A Canadian AOL Company

Brad Spencer <spencer@infointeractive.com> 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

On Fri, Apr 02, 2004 at 06:02:30PM -0500, David Abrahams wrote:
Brad Spencer <spencer@infointeractive.com> 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?
It's in <ia32/sys/reg.h>, which I don't include directly, but ends up in the compilation. It looks like it's inside some guards (again, which I am not setting directly), but they must resolve to true.
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.
Ok. In this case the macros have a single capital letter and a number.
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.
Hmmm. What should I do then? -- ------------------------------------------------------------------ Brad Spencer - spencer@infointeractive.com - "It's quite nice..." Systems Architect | InfoInterActive Corp. | A Canadian AOL Company

Brad Spencer <spencer@infointeractive.com> writes:
On Fri, Apr 02, 2004 at 06:02:30PM -0500, David Abrahams wrote:
Brad Spencer <spencer@infointeractive.com> 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?
It's in <ia32/sys/reg.h>, which I don't include directly, but ends up in the compilation. It looks like it's inside some guards (again, which I am not setting directly), but they must resolve to true.
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.
Ok. In this case the macros have a single capital letter and a number.
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.
Hmmm. What should I do then?
At the very least we ought to find all of the R1,...R9 identifiers in Boost and fix them. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
Brad Spencer
-
David Abrahams