|
From: Matthias S. <zz...@ge...> - 2016-01-12 22:14:38
|
When compiling code that includes valgrind.h on visual studio I get compiler errors about VALGRIND_PRINTF: 1>include\Valgrind/valgrind.h(4493) : error C2220: warning treated as error - no 'object' file generated 1>include\Valgrind/valgrind.h(4493) : warning C4100: 'format' : unreferenced formal parameter 1>include\Valgrind/valgrind.h(4531) : warning C4100: 'format' : unreferenced formal parameter See https://bugs.kde.org/show_bug.cgi?id=356817 There are multiple ways to fix this issue. 1. Complicated one: extend the existing ifdef code with special NVALGRIND function versions for gcc and MSVC, see https://bugs.kde.org/attachment.cgi?id=96139 2. Simple one: have a function or macro with only "..." argument in the NVALGRIND case that does nothing. --- a/include/valgrind.h +++ b/include/valgrind.h @@ -6746,6 +6746,18 @@ typedef is the number of characters printed, excluding the "**<pid>** " part at the start and the backtrace (if present). */ +#if defined(_MSC_VER) && defined(NVALGRIND) +static int __inline VALGRIND_PRINTF(...) +{ + return 0; +} + +static int __inline VALGRIND_PRINTF_BACKTRACE(...) +{ + return 0; +} + +#else /* _MSC_VER && NVALGRIND */ #if defined(__GNUC__) || defined(__INTEL_COMPILER) && !defined(_MSC_VER) /* Modern GCC will optimize the static routine out if unused, and unused attribute will shut down warnings about it. */ @@ -6823,7 +6835,7 @@ VALGRIND_PRINTF_BACKTRACE(const char *format, ...) return (int)_qzz_res; #endif /* NVALGRIND */ } - +#endif /* _MSC_VER && NVALGRIND */ /* These requests allow control to move from the simulated CPU to the real CPU, calling an arbitary function. What do you think about this? Regards Matthias |