[CMake] test files generated by CheckIncludeFile are not ansi conform

Brad King brad.king at kitware.com
Tue May 16 14:11:50 EDT 2006


Michael Biebl wrote:
> The template files for CheckIncludeFile are not ansi conform, this
> means running with "CFLAGS=-Werror -Wstrict-prototypes" produces
> failing tests.
> 
> The template file CheckIncludeFile.c.in and the one for cxx should
> correctly read
> 
> #include <${CHECK_INCLUDE_FILE_VAR}>
> 
> int main(int argc, char *argv[])
> {
>  return 0;
> }

The -Werror flag will still cause a failure if the compiler warns about 
unused argc/argv.

Actually, in C++ it is perfectly standard to have no main arguments:

   int main() { return 0; }

The problem is in C (which I know is your problem because 
-Wstrict-prototypes does not work in C++), where the check must work 
both for strict ANSI compilers and for non-ANSI compilers like the old 
HP C compiler.  Something like this is needed:

#ifdef __CLASSIC_C__
int main() { return 0; }
#else
int main(void) { return 0; }
#endif

Anyway, we'll fix it.

-Brad


More information about the CMake mailing list