Similar to what __FUNCTION__
does for the current function, Is there a preprocessor macro to get the name of the current class?
Asked
Active
Viewed 2.4k times
15

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

Damian
- 5,471
- 11
- 56
- 89
-
What for? There may be other ways. – GManNickG Mar 25 '11 at 00:08
-
Look at [https://stackoverflow.com/questions/1666802/class-macro-in-c](https://stackoverflow.com/questions/1666802/class-macro-in-c) – Adam Trhon Mar 25 '11 at 00:06
1 Answers
2
No, there is no such macro - sorry.
But nevertheless: __FUNCTION__
(or __PRETTY_FUNCTION__
with gcc) should give you the name of the enclosing class - you just have to extract it.

Alexander Gessler
- 45,603
- 7
- 82
- 122