Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Стандартизировать макрос __COUNTER__ #576

Open
kov-serg opened this issue Sep 7, 2023 · 2 comments
Open

Стандартизировать макрос __COUNTER__ #576

kov-serg opened this issue Sep 7, 2023 · 2 comments

Comments

@kov-serg
Copy link

kov-serg commented Sep 7, 2023

Стандартизировать макрос __COUNTER__

Что бы не городить такое https://github.com/madmurphy/zen.h/blob/master/zen.h

Полезные ссылки:
https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros

@xiran56
Copy link

xiran56 commented Jan 1, 2024

В репозитории, на который вы дали ссылку, написано:

There are two main reasons for implementing a novel counter for the C preprocessor other than the built-in (and non-standard) COUNTER. The first reason is that COUNTER is not flexible: when two or more headers use it, the values that this yields are not predictable. The second and most important reason is that COUNTER is not reusable and gets increased every time it is invoked, making the storage of its yielded values within the preprocessor environment virtually impossible.

Это уже несколько причин его не стандартизировать.

@kov-serg
Copy link
Author

kov-serg commented Jan 1, 2024

Ничто не мешает сделать нечто что будет увеличиваться при его чтении, но на уровне компиляции. Типа std::source_location::counter()
__COUNTER__ у многих компиляторов есть из коробки. Но в стандарте ничего подобного нет.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants