Bug 356817

Summary: valgrind.h triggers compiler errors on MSVC when defining NVALGRIND
Product: [Developer tools] valgrind Reporter: Matthias Schwarzott <zzam>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: flo2030
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: valgrind-h-fix-MSVC-warning-v1

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.