]> git.draconx.ca Git - dxcommon.git/commit
xtra: Avoid undefined ## usage.
authorNick Bowler <nbowler@draconx.ca>
Mon, 23 Jan 2023 04:34:16 +0000 (23:34 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 23 Jan 2023 05:05:47 +0000 (00:05 -0500)
commite1ebfe7f258c1c99006fee8a3b6e111dc1d34d79
tree83c65a56ec8fb381fc6686f40762f53f233ae450
parent6fb8cf34b6e66e2b81d53f0d166fd2a6db6b01fb
xtra: Avoid undefined ## usage.

According to the C spec, every use of the ## operator has to produce a
valid preprocessing token, otherwise the behaviour is undefined.  It is
not enough to merely ensure that a sequence of ## operators results in
a valid token at the end.

This matters in practice, as at least some versions of the Sun Studio
compiler will turn:

  #define PASTE(a, b) a ## b
  #define PASTE2(a, b) PASTE(a, b)

  PASTE2(uint_least, PASTE(8, _t))

into two tokens:

  uint_least8 _t

instead of uint_least8_t as desired.  The results are not good for
the XTRA_PACKED_LOPTS macro.  Fortunately, it is straightforward to
rearrange the expansions to avoid this problem.
src/xtra.h