When debug, I how to out put the name of the function.

P

Peng Yu

For example, I have a function called test, I want to output the name
of the function. Is there any macro for it?

Peng

int test(){
....
cout << the name of the funcion

}
 
V

Victor Bazarov

Peng said:
For example, I have a function called test, I want to output the name
of the function. Is there any macro for it?

Peng

int test(){
...
cout << the name of the funcion

cout << "test()";


No, there is no macro in the language, although some compilers do provide
__PRETTY_FUNCTION__ or something of that sort.

V
 
D

David Lindauer

Victor said:
cout << "test()";


No, there is no macro in the language, although some compilers do provide
__PRETTY_FUNCTION__ or something of that sort.

V

I think there is a mechanism for this in C99 standard, is there any thought
about putting it in the next C++ standard as well?

Thanks,

David
 
V

Victor Bazarov

David said:
Victor Bazarov wrote:




I think there is a mechanism for this in C99 standard, is there any thought
about putting it in the next C++ standard as well?

C99 has __func__, which has type 'const char[]'. There is a proposal
(n1650) that... [www.open-std.org is sooooo sloooooow today]... that...
probably mentions __func__, I have no patience to wait for that server
to send me back the article.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top