[cmake-developers] [CMake 0015058]: CheckIncludeFiles uses old-style function definition
Mantis Bug Tracker
mantis at public.kitware.com
Mon Aug 4 23:04:00 EDT 2014
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=15058
======================================================================
Reported By: Nate Eldredge
Assigned To:
======================================================================
Project: CMake
Issue ID: 15058
Category: Modules
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2014-08-04 23:04 EDT
Last Modified: 2014-08-04 23:04 EDT
======================================================================
Summary: CheckIncludeFiles uses old-style function definition
Description:
The CheckIncludeFiles module uses a trivial C program that looks like
int main(){return 0;}
Note the absence of a prototype in the definition of main (modern C would use
"int main(void)"). If appropriate warning are in effect, gcc will barf on this
and cause the CHECK_INCLUDE_FILES test to fail.
Steps to Reproduce:
nate at minerva:~/bugs/cmake$ ls
build CMakeLists.txt
nate at minerva:~/bugs/cmake$ cat CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE (CheckIncludeFiles)
PROJECT (Hello)
SET(CMAKE_C_FLAGS "-Wold-style-definition -Werror")
CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
nate at minerva:~/bugs/cmake$ cd build
nate at minerva:~/bugs/cmake/build$ /tmp/bin/cmake --version
cmake version 3.0.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
nate at minerva:~/bugs/cmake/build$ /tmp/bin/cmake ..
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include file stdio.h
-- Looking for include file stdio.h - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nate/bugs/cmake/build
Note that it incorrectly reports that stdio.h was not found.
CMakeFiles/CMakeError.log contains:
Determining if files stdio.h exist failed with the following output:
Change Dir: /home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec2688096886/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec2688096886.dir/build.make
CMakeFiles/cmTryCompileExec2688096886.dir/build
make[1]: Entering directory `/home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp'
/tmp/bin/cmake -E cmake_progress_report
/home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object
CMakeFiles/cmTryCompileExec2688096886.dir/CheckIncludeFiles.c.o
/usr/bin/cc -Wold-style-definition -Werror -o
CMakeFiles/cmTryCompileExec2688096886.dir/CheckIncludeFiles.c.o -c
/home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
/home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp/CheckIncludeFiles.c: In function
‘main’:
/home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:5:5: error:
old-style function definition [-Werror=old-style-definition]
int main(){return 0;}
^
cc1: all warnings being treated as errors
make[1]: *** [CMakeFiles/cmTryCompileExec2688096886.dir/CheckIncludeFiles.c.o]
Error 1
make[1]: Leaving directory `/home/nate/bugs/cmake/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec2688096886/fast] Error 2
Source:
/* */
#include <stdio.h>
int main(){return 0;}
Additional Information:
I've attached the obvious patch to Modules/CheckIncludeFiles.cmake
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-08-04 23:04 Nate Eldredge New Issue
2014-08-04 23:04 Nate Eldredge File Added: CheckIncludeFiles.patch
======================================================================
More information about the cmake-developers
mailing list