Est-il possible d'obtenir le nom de la fonction à l'intérieur d'une fonction C++?

Je veux implémenter une fonction traceur, qui serait la trace de combien de temps une fonction est prise à exécuter. J'ai suivantes de la classe pour la même chose:-

class FuncTracer
{
    public:
        FuncTracer(LPCTSTR strFuncName_in)
        {
            m_strFuncName[0] = _T('
class FuncTracer
{
public:
FuncTracer(LPCTSTR strFuncName_in)
{
m_strFuncName[0] = _T('\0');
if( strFuncName_in ||
_T('\0') != strFuncName_in[0])
{   
_tcscpy(m_strFuncName,strFuncName_in);
TCHAR strLog[MAX_PATH];
_stprintf(strLog,_T("Entering Func:- <%s>"),m_strFuncName);
LOG(strLog)
m_dwEnterTime = GetTickCount();
}
}
~FuncTracer()
{
TCHAR strLog[MAX_PATH];
_stprintf(strLog,_T("Leaving Func:- <%s>, Time inside the func <%d> ms"),m_strFuncName, GetTickCount()-m_dwEnterTime);
LOG(strLog)
}
private:
TCHAR m_strFuncName[MAX_PATH];
DWORD m_dwEnterTime;
};
void TestClass::TestFunction()
{
//I want to avoid writing the function name maually..
//Is there any macro (__LINE__)or some other way to 
//get the function name inside a function ??
FuncTracer(_T("TestClass::TestFunction"));
/*
* Rest of the function code.
*/
}
'
); if( strFuncName_in || _T('
class FuncTracer
{
public:
FuncTracer(LPCTSTR strFuncName_in)
{
m_strFuncName[0] = _T('\0');
if( strFuncName_in ||
_T('\0') != strFuncName_in[0])
{   
_tcscpy(m_strFuncName,strFuncName_in);
TCHAR strLog[MAX_PATH];
_stprintf(strLog,_T("Entering Func:- <%s>"),m_strFuncName);
LOG(strLog)
m_dwEnterTime = GetTickCount();
}
}
~FuncTracer()
{
TCHAR strLog[MAX_PATH];
_stprintf(strLog,_T("Leaving Func:- <%s>, Time inside the func <%d> ms"),m_strFuncName, GetTickCount()-m_dwEnterTime);
LOG(strLog)
}
private:
TCHAR m_strFuncName[MAX_PATH];
DWORD m_dwEnterTime;
};
void TestClass::TestFunction()
{
//I want to avoid writing the function name maually..
//Is there any macro (__LINE__)or some other way to 
//get the function name inside a function ??
FuncTracer(_T("TestClass::TestFunction"));
/*
* Rest of the function code.
*/
}
'
) != strFuncName_in[0]) { _tcscpy(m_strFuncName,strFuncName_in); TCHAR strLog[MAX_PATH]; _stprintf(strLog,_T("Entering Func:- <%s>"),m_strFuncName); LOG(strLog) m_dwEnterTime = GetTickCount(); } } ~FuncTracer() { TCHAR strLog[MAX_PATH]; _stprintf(strLog,_T("Leaving Func:- <%s>, Time inside the func <%d> ms"),m_strFuncName, GetTickCount()-m_dwEnterTime); LOG(strLog) } private: TCHAR m_strFuncName[MAX_PATH]; DWORD m_dwEnterTime; }; void TestClass::TestFunction() { //I want to avoid writing the function name maually.. //Is there any macro (__LINE__)or some other way to //get the function name inside a function ?? FuncTracer(_T("TestClass::TestFunction")); /* * Rest of the function code. */ }

Je veux savoir si il y a moyen d'obtenir le nom de la fonction à partir de l'intérieur d'une fonction? Fondamentalement, je veux que les utilisateurs de ma classe il suffit de créer un objet de même. Ils ne peuvent pas transmettre le nom de la fonction.

InformationsquelleAutor Canopus | 2009-04-09