naphaso / cbor-cpp

CBOR C++ serialization library
75 stars 29 forks source link

log.h __PRETTY_FUNCTION__ is not supported in Visual Studio #6

Open bialix opened 8 years ago

bialix commented 8 years ago

Trying to compile your library under Visual Studio - I was forced to change your log.h to use just plain __FUNCTION__ macro instead of __PRETTY_FUNCTION__.

Search on MSDN revealed this: https://social.msdn.microsoft.com/Forums/vstudio/en-US/02c69018-a182-48b3-94d1-250252aa00a7/prettyfunction?forum=vclanguage

etanot commented 6 years ago

__PRETTY_FUNCTION__ is a gcc extension. In Visual C++ you can use __FUNCSIG__ which isn't quite identical to __PRETTY_FUNCTION__ extension.

VC++ :

// Demonstrates functionality of __FUNCTION__, __FUNCDNAME__, and __FUNCSIG__ macros
void exampleFunction()
{
    printf("Function name: %s\n", __FUNCTION__);
    printf("Decorated function name: %s\n", __FUNCDNAME__);
    printf("Function signature: %s\n", __FUNCSIG__);

    // Sample Output
    // -------------------------------------------------
    // Function name: exampleFunction
    // Decorated function name: ?exampleFunction@@YAXXZ
    // Function signature: void __cdecl exampleFunction(void)
}

Reference : MSDN