Bug 356817 - valgrind.h triggers compiler errors on MSVC when defining NVALGRIND
Summary: valgrind.h triggers compiler errors on MSVC when defining NVALGRIND
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-17 07:16 UTC by Matthias Schwarzott
Modified: 2016-01-17 16:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
valgrind-h-fix-MSVC-warning-v1 (2.22 KB, patch)
2015-12-17 07:19 UTC, Matthias Schwarzott
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Schwarzott 2015-12-17 07:16:01 UTC
When compiling sources on MSVC with NVALGRIND being defined, it shows this error:
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


Reproducible: Always
Comment 1 Matthias Schwarzott 2015-12-17 07:19:33 UTC
Created attachment 96139 [details]
valgrind-h-fix-MSVC-warning-v1

This patch fixes the issue.
But it looks a bit complicated.
It defines two different versions for VALGRIND_PRINTF depending on if compiler is gcc (understands __attribute__(unused) or not).
Maybe it would be simpler to just have this version for all compilers in case of NVALGRIND:
static int
#if defined(_MSC_VER)
__inline
#endif
VALGRIND_PRINTF(...)
{
   return 0;
}
Comment 2 Florian Krohm 2016-01-17 16:20:59 UTC
Fixed in r15762.