[lug] C++ question, without buying expensive doc.s
Chan Kar Heng
karheng at softhome.net
Tue Jan 11 09:35:16 MST 2005
>There is a predefined in GNU C++ whose name is __FUNCTION__ . This
>evaluates to the name of the function that is currently being compiled.
>I think this can be used to store the name of a class in the date
>contained in its instances. This is useful for serialize/deserialize.
>But I wonder if:
>a. is this standards compliant
>b. is there some other standards compliant predefine that would be better
>
>I found __FUNCTION__ is some Visual C++ documentation and tried it in
>GNU C++ and it worked. Visual C++ also has __TIMESTAMP__ which does not
>work in GNU C++. So, this appears to be an area of variability among
>compilers.
the closest i've seen is __func__ which is actually a
string variable (not a macro) automatically defined in
every function, containing the name of that function.
for a C++ class member function, the string doesn't have
the class name part.
however, coupled with RTTI, you might just get what
you want...
it (__func__) works with most C99 compliant compilers
as far as i know.
compilers before C99 don't support it if i'm not mistaken.
havn't come across __FUNCTION__...
would it simply be a macro for __func__ ?
anyway, i've tried digging for predefined macros once...
and doing a google on several rarely encountered macros
at the same time can churn out some interesting pages.
rgds,
kh
More information about the LUG
mailing list