C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Preprocessor multi-line macroes

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Wed, 24 Jun 2026 23:44:06 +0200
Did you run this past WG14? What's their interest?

Jens


On 6/24/26 23:33, Frederick Virchanza Gotham via Std-Proposals wrote:
> Instead of doing this:
>
> #define ASSERT_EQ(a, b) \
> do \
> { \
> if ( (a) == (b) ) break; \
> \
> std::fprintf(stderr, #a " != " #b " at %s:%d\n", \
> __FILE__, __LINE__); \
> std::abort(); \
> } while (0)
>
> Wouldn't it be nice to be able to do this:
>
> #define ASSERT_EQ(a, b) \\\
> do
> {
> if ( (a) == (b) ) break;
>
> std::fprintf(stderr, #a " != " #b " at %s:%d\n",
> __FILE__, __LINE__);
> std::abort();
> } while (0)
> \\\
>
> I'm told back in the 1990's, a guy called Andrew Myers made a patch
> for GNU gcc so that you could do:
>
> #begin define swap(x,y,T)
> do {
> T temp = x;
> x = y;
> y = temp;
> } while (0)
> #end
>
> Whether we use three backslashes or "'#begin define", this should be
> standardised in C++29.

Received on 2026-06-24 21:44:10