Boost logo

Boost :

Subject: [boost] [Math.Constants] Help needed with the preprocessor
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-12-16 13:23:52

Folks we have a problem: rather late in the day I've discovered that our
Math.Constants code doesn't compile on anything except VC++, and the problem
is preprocessor token pasting. So I'm hoping we have some experts around
here that can help!

The issue is we currently construct the constants from a macro invocation
such as:

  BOOST_DEFINE_MATH_CONSTANT(half, 5.000000000000000000000000000000000000,

But the "-01" part (the exponent) isn't a valid pp-token, so trying to
token-paste it fails on GCC (compiler error).

Does anyone know if there's a way to overcome this?

As an alternative, I've considered something like:


But this would still require token pasting of the


part. But is this now a valid pp-token if the "-" is internal to the token?
It works on the compilers I've tried, but I don't want to be skewered by
this again down the line....

Truly hating the preprocessor yours, John.

Boost list run by bdawes at, gregod at, cpdaniel at, john at