[Piglit] [PATCH 3/3] cmake: Use -Werror=pointer-arith on GCC builds.

Martin Peres martin.peres at linux.intel.com
Tue Mar 3 06:05:15 PST 2015


Reviewed-by: Martin Peres <martin.peres at linux.intel.com>

On 03/03/15 15:46, Jose Fonseca wrote:
> Void pointer arithmetic is not supported on MSVC, so passing
> -Werror=pointer-arith will make it easier for everybody to catch this
> sort of portability issues as the code is written.
> ---
>   CMakeLists.txt | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 94c0958..19028cb 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -215,6 +215,12 @@ if (NOT MSVC)
>   	IF (C_COMPILER_FLAG_WEVLA)
>   		SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=vla")
>   	ENDIF ()
> +	# GCC allows void pointer arithmetic, but it is not part of ISO C and
> +	# in particular MSVC will throw `C2036: 'void *' : unknown size`
> +	check_c_compiler_flag ("-Werror=pointer-arith" C_COMPILER_FLAG_WEPOINTER_ARITH)
> +	if (C_COMPILER_FLAG_WEPOINTER_ARITH)
> +		set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=pointer-arith")
> +	endif ()
>   	# MSVC only supports C99 variadic macros.  It doesn't support the
>   	# non-standard GNU named variadic macro syntax that's documented in
>   	# https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html



More information about the Piglit mailing list