RFR: 8086027: Multiple STATIC_ASSERTs at class scope doesn't work
kim.barrett at oracle.com
Tue Jun 9 18:39:21 UTC 2015
On Jun 9, 2015, at 2:17 AM, David Holmes <david.holmes at oracle.com> wrote:
> Hi Kim,
> On 9/06/2015 3:51 PM, Kim Barrett wrote:
>> Third time's the charm?
>> Please review this change to the STATIC_ASSERT macro, to allow
>> multiple assertions in the same class scope.
>> It seems we do need to make the typedef names used in the expansion
>> unique per scope; see CR for details. We accomplish this with
>> preprocessor token pasting with __LINE__ (done correctly, unlike in
>> the change for JDK-8067306).
> Seems okay to me (but then so did previous version <sigh>).
Thanks for reviewing. And yeah, sorry about that.
>> As part of this, I'm also adding PASTE_TOKENS(x, y) utility macro.
>> I'm willing to entertain alternative naming suggestions, though hoping
>> to avoid a bikeshed discussion.
> As we already have XSTR for the single token case, what about XSTRCAT ?
As there aren’t any strings involved, only pp tokens, I don’t care for a name related to strings.
Bengt’s suggestion of XCAT is a better match for the existing XSTR, but I dislike short global
macro names as being too easy for collisions to occur. For an example of the problem, see
the little dance around STR in os/solaris/vm/attachListener_solaris.cpp.
And I’m not sure what the X prefix is supposed to indicate. Maybe XCAT is supposed to be
eXtended conCATenation? I prefer words.
I chose the current name based on a common name for ## being the “token pasting operator”.
It’s also sometimes referred to as joining rather than pasting, though that seems less frequent.
C++ standards just call it the “## operator”, though there’s an example in C++11 that defines a
macro called “join” that uses it. And some commonly used libraries do use “cat”. (Boost has
both BOOST_PP_CAT and BOOST_JOIN, which have different implementations because
they use different approaches to detecting and working around preprocessor deficiencies.)
But I wouldn’t want to use “JOIN” because that already has other meanings, such as with thread
I guess that’s a long-winded way of saying I’m planning to stick with PASTE_TOKENS.
More information about the hotspot-dev