C++ Logo


Advanced search

Re: [std-proposals] Preprocessor macro __COUNTER__

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Tue, 16 Aug 2022 11:02:40 -0400
On Tue, Aug 16, 2022 at 10:26 AM Lénárd Szolnoki via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On 16 August 2022 12:53:00 BST, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>> Every C++ compiler suite I'm aware of supports the preprocessor
macro __COUNTER__.
> It is an ODR-violation footgun when used in header files.

I think `__COUNTER__` can be useful; but it's just like `#pragma once` —
every vendor already supports it, a fair bit of code depends on it, so
what's the point of all the bickering to add it to the Standard? It's
easier to just maintain the status quo, which is that it's non-standard but
it works.

For comparison, C++ once tried to standardize the equally widespread vendor
practice of
    #define CALL(...) call(1, 2, 3 ,##__VA_ARGS__)
to mean "eliminate the trailing comma if __VA_ARGS__ is empty," and after
they got through with it we ended up with a whole new thing called
__VA_OPT__, and the original code remains a non-standard extension.


Received on 2022-08-16 15:02:53