I have defined the following pre-processor directive:
#define TIMER(name) ::my_app::Timer timer##__LINE__(name)
Using as follows:
TIMER("first");
TIMER("second");
I get an error stating that the second usage redefines timer__LINE__
.
::my_app::Timer timer__LINE__("first");
::my_app::Timer timer__LINE__("second");
What I actually want is a definition of timer with the source code line number appened, e.g.:
::my_app::Timer timer1("first");
::my_app::Timer timer2("second");
If it's any use, my clang version details:
❯ /Library/Developer/CommandLineTools/usr/bin/clang --version
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I see examples of where this syntax is used and works (::Hazel::InstrumentationTimer timer##__LINE__(fixedName.Data)
). Why is the token pasting operator not working as I'd expect in my scenario?