I am trying to auto generate a string that can be used in debug logs, the syntax I would like is:
    ClassName::FunctionName
The source code can be used on two systems with different compilers, this includes:
    Microsoft Visual Studio 2010, Version 10.0.40219.1 SP1Rel
and
    QNX Momentics, Version 4.7
I've tried this so far:
    #if defined(__FUNCDNAME__)
      #define FNAME    __FUNCDNAME__
    #elif defined(__FUNCTION__)
      #define FNAME    __FUNCTION__
    #elif defined(__FUNSIG__)
      #define FNAME    __FUNSIG__
    #elif defined(__func__)
      #define FNAME    __func__
    #elif defined(__PRETTY_FUNCTION__)
      #define FNAME    __PRETTY_FUNCTION__
    #else
      #define FNAME    ""
    #endif
I then added a bit of test code so I could see the result in the debugger:
    char szTemp[128];
    strcpy_s(szTemp, sizeof(szTemp), FNAME);
The result is not what I am after:
    ??0CLSNAME@@QAE@AAV?$SecBlock@EV?$AllocatorWithCleanup@ES0A@@@@@@0_N@Z
I have no idea what this is.
[Edit] I Changed the pre-processor's to give me a bit more visibility as to what is happening, now the code reads:
    szFrom[0] = '\0';
    #if defined(__PRETTY_FUNCTION__)
      #define FNAME    __PRETTY_FUNCTION__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__FUNCTION__)
      #define FNAME    __FUNCTION__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__FUNCDNAME__)
      #define FNAME    __FUNCDNAME__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__FUNSIG__)
      #define FNAME    __FUNSIG__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__func__)
      #define FNAME    __func__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
When using MSVC I can see the flow and ugly output comes from FUNCDNAME which is the only condition that the flow goes into.
[Edit 2] Final working solution:
    szFrom[0] = '\0';
    #if defined(__PRETTY_FUNCTION__)
      #define FNAME    __PRETTY_FUNCTION__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__FUNCTION__)
      #define FNAME    __FUNCTION__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__FUNSIG__)
      #define FNAME    __FUNSIG__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
    #if defined(__func__)
      #define FNAME    __func__
      strcpy_s(szFrom, sizeof(szFrom), FNAME);
    #endif
On MSVC this gives the output:
    ClassName::FunctionName
Thanks go to P.W.
 
     
    