Date: Sat, 24 Aug 2024 20:05:23 +0300
On 8/24/24 19:52, Jeremy Rifkin wrote:
>
>> If you don't want to reference the name then the only use case I can
> think of is to leverage its construction and destruction side effects.
>
> This is what google benchmark uses it for
> https://godbolt.org/z/fh5f1qY3G. Standardizing
> __attribute__((constructor)) would probably be more controversial, and
> it wouldn't solve this use case unless paired with an anonymous
> namespace.
As far as I can see, this is exactly what __attribute__((constructor))
is for. I don't know this Google benchmark library, and there may be
features that require a namespace scope object, but the code you
presented doesn't.
>
>> If you don't want to reference the name then the only use case I can
> think of is to leverage its construction and destruction side effects.
>
> This is what google benchmark uses it for
> https://godbolt.org/z/fh5f1qY3G. Standardizing
> __attribute__((constructor)) would probably be more controversial, and
> it wouldn't solve this use case unless paired with an anonymous
> namespace.
As far as I can see, this is exactly what __attribute__((constructor))
is for. I don't know this Google benchmark library, and there may be
features that require a namespace scope object, but the code you
presented doesn't.
Received on 2024-08-24 17:05:34