[Piglit] [PATCH] cmake: Enable __USE_MINGW_ANSI_STDIO for MinGW builds.
Vinson Lee
vlee at freedesktop.org
Mon Aug 17 21:11:02 PDT 2015
MSVC is currently already building getprogramresourceiv.c without any
format-related warnings. Also, this proposed patch would only apply to
the MinGW build and have no effect the MSVC build.
On Mon, Jul 20, 2015 at 11:51 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> Interesting, I didn't know about __USE_MINGW_ANSI_STDIO.
>
> However, it solves the MinGW problem, but not MSVC --
> https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
>
> A more portable solution would be to use inttypes.h PRIdPTR or avoid size_t
> arguments to printf.
>
> Jose
>
>
> On 21/07/15 05:23, Vinson Lee wrote:
>>
>> Fix printf compiler warnings.
>>
>> getprogramresourceiv.c: In function 'check_prop':
>> getprogramresourceiv.c:747:20: warning: unknown conversion type character
>> 'z' in format [-Wformat=]
>> fprintf(stderr, "'%s' expected %zu entries but got %i"
>
>
>
>> ^
>> getprogramresourceiv.c:747:20: warning: format '%i' expects argument of
>> type 'int', but argument 4 has type 'size_t {aka long long unsigned int}'
>> [-Wformat=]
>> getprogramresourceiv.c:747:20: warning: too many arguments for format
>> [-Wformat-extra-args]
>> getprogramresourceiv.c:828:20: warning: unknown conversion type character
>> 'z' in format [-Wformat=]
>> fprintf(stderr, "'%s' expected %zu entries but got %i"
>> ^
>> getprogramresourceiv.c:828:20: warning: format '%i' expects argument of
>> type 'int', but argument 4 has type 'size_t {aka long long unsigned int}'
>> [-Wformat=]
>> getprogramresourceiv.c:828:20: warning: too many arguments for format
>> [-Wformat-extra-args]
>>
>> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
>> ---
>> CMakeLists.txt | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>> index 99d9a8e..95a6b31 100644
>> --- a/CMakeLists.txt
>> +++ b/CMakeLists.txt
>> @@ -280,6 +280,8 @@ if (MINGW)
>> set (CMAKE_SHARED_LINKER_FLAGS
>> "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
>> set (CMAKE_MODULE_LINKER_FLAGS
>> "${CMAKE_MODULE_LINKER_FLAGS} -static-libstdc++")
>> endif ()
>> +
>> + add_definitions(-D__USE_MINGW_ANSI_STDIO)
>> endif ()
>>
>> if (${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
>>
>
More information about the Piglit
mailing list