0

I would like to have a macro that produce something like L17, where 17 is the line number when the macro is invoked. However the following only produce L__LINE__

#define STOP L##__LINE__

Wonder if there is a way to make the __LINE__ evaluate before concatenation.

packetie
  • 4,839
  • 8
  • 37
  • 72

1 Answers1

3

You need a double concat macro wrapper:

#define CONCAT0(x,y) x ## y
#define CONCAT(x,y) CONCAT0(x,y)
#define STOP CONCAT(L,__LINE__)
int main() {
    int STOP = 42;
    L5 = 41;
}