3 ms·
We use this (trick taken from stackoverflow) to make __COUNTER__ usefully provide unique, reusable names: https://gitlab.com/nbdkit/nbdkit/-/blob/master/common
by rwmj 4y ago
We use this (trick taken from stackoverflow) to make __COUNTER__ usefully provide unique, reusable names:
https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/include/unique-name.h https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/includ...
Example use for MIN and MAX macros which evaluate the parameters once and can be nested to any depth:
https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/include/minmax.h https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/includ...
I don't know what __EXP_COUNTER__ would add.
- kazinator 4y agoYour NBDKIT_UNIQUE_NAME(name) cannot produce the same name twice because it doesn't take a counter as a parameter. __EXP_COUNTER__ adds the ability for a macro expansion to have its own counter for that expansion instance, without some other macro having to hand it one as a an extra, visible parameter.