[CMake] conflicting types for built-in function 'snprintf'

Eric Noulard eric.noulard at gmail.com
Wed Jul 8 09:08:26 EDT 2009


2009/7/8 Hendrik Sattler <post at hendrik-sattler.de>:
> Zitat von Eric Noulard <eric.noulard at gmail.com>:
>>
>> It works for me and the CMakeFiles/CMakeOutput.log reads:
>>
>> Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o
>> /usr/bin/gcc  -DWHAT=ever -DCHECK_FUNCTION_EXISTS=snprintf
>> -fno-builtin   -o
>> CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o   -c
>> /home/eric/CMake/cmake-V2_6/share/cmake-2.6/Modules/CheckFunctionExists.c
>>
>> which is the expect command line.
>
> It's not. The OP use additional -W parameters like -Werror.
> Actually, the test should be made work with -Wall -Wextra -Werror.

Ok right that's because I forget to add those flags in my "too-simple"
test case,
the fact is if you add:

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")

 before

SET(CMAKE_REQUIRED_FLAGS "-fno-builtin")


Then you get in the log:

Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o
/usr/bin/gcc   -Wall -Wextra -Werror  -DCHECK_FUNCTION_EXISTS=snprintf
-fno-builtin   -o
CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o   -c
/home/eric/CMake/cmake-V2_6/share/cmake-2.6/Modules/CheckFunctionExists.c

which **should** be the expected command line :-)

not to mentionned that the "snprintf" is FOUND with the extra
SET(CMAKE_REQUIRED_FLAGS "-fno-builtin")

and is "not found" without it.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list