Macro __FUNCTION__ in C++

Tim Hollebeek tim@wagner.princeton.edu
Sun Sep 13 04:58:00 GMT 1998


Ryszard Kabatek writes ...
> 
> The macro __FUNCTION__, or in C9X draft the identifier __func__, 
> returns the name of the current function without
> the namespace and without the argument types.
> 
> It's good for the C language, but in C++ would be useful something like:
> 
> namespace A {
> class B {
>   public:
>     void calc(int x, double y) const {cout << __FUNCTION__ << '\n'; /**/}
> };
> }
> 
> '::A::B::calc(int, double) const' instead of 'calc'

Do you know about __PRETTY_FUNCTION__ ?

g++ 2.7.2 prints "void B::calc(int, double) const' for this example; I don't
know if the latest egcs will put the namespace in front of that or not.

---------------------------------------------------------------------------
Tim Hollebeek                           | "Everything above is a true
email: tim@wfn-shop.princeton.edu       |  statement, for sufficiently
URL: http://wfn-shop.princeton.edu/~tim |  false values of true."



More information about the Gcc mailing list