If you’re using GCC or MSVC, there is __COUNTER__
.
Other than that, you could do something vomit-worthy, like:
#ifndef USED_1
#define USED_1
1
#else
#ifndef USED_2
#define USED_2
2
/* many many more */
#endif
#endif
More Related Contents:
- Variadic recursive preprocessor macros – is it possible?
- How do I show the value of a #define at compile-time?
- The need for parentheses in macros in C [duplicate]
- Overloading Macro on Number of Arguments
- C macros and use of arguments in parentheses
- Real-world use of X-Macros
- Can we have recursive macros?
- What exactly do C include guards do?
- Array-size macro that rejects pointers
- Is it possible to declare variables procedurally using Rust macros?
- Generating documentation in macros
- Macros in Swift?
- How to prefix/suffix identifiers within a macro? [duplicate]
- How to identify platform/compiler from preprocessor macros?
- What are C macros useful for?
- Opposite of C preprocessor “stringification”
- How do I match the type of an expression in a Rust macro?
- macro definition containing #include directive
- Can I redefine a C++ macro then define it back?
- C# Macro definitions in Preprocessor
- Is there a way to count with macros?
- Confused by squaring macro SQR in c [duplicate]
- How to write macro for Notepad++?
- How to auto execute a macro when opening a Powerpoint presentation?
- Mathematica: Unevaluated vs Defer vs Hold vs HoldForm vs HoldAllComplete vs etc etc
- Expand macro inside string literal
- How to embed a Rust macro variable into documentation?
- offsetof at compile time
- How to enforce that a type implements a trait at compile time?
- Macros to create strings in C