[Qt-interest] How to get a string with the current function name?

Christian Gagneraud cgagneraud at techworks.ie
Tue Nov 30 19:04:50 CET 2010


On 11/30/2010 05:32 PM, Marcelo Magno T. Sales wrote:
> Hello,
>
> Is it possible to get the current function/method name in a string, for
> debugging purposes? How?

With GCC, you can use:
__FILE__
__LINE__
__FUNCTION__

What I usually do is something like:
#define DEBUG qDebug() << __FILE__ << __LINE__ << __FUNCTION__

then you can use it like
DEBUG;

or

DEBUG << "some messages" << some_var;

When I use emacs, I format the debug message like this 
"file.cpp:function():666", so that you can jump to the code from the 
message in the buffer.
Unfortunately I don't know any equivalent functionalities for 
QtCreator, if anyone knows...


Regards,
Chris

>
> Thanks,
>
> Marcelo
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest


-- 
Christian Gagneraud,
Electronics and software engineer

TechWorks Marine Ltd
4a, Park Lane
Dun Laoghaire, Co Dublin
Ireland

Tel: + 353 1 2365990
Fax: + 353 1 2365992
Web: www.techworks.ie





More information about the Qt-interest-old mailing list