From 44fa5b19f71e2441a22d308fae8487295e7ce63c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 23 Apr 2018 01:50:55 +0300 Subject: [PATCH] Fix CheckFunctionExistsEx() cmake macro on win32 For example under mingw64 it could not detect that strtok_r() exists, because it checks with: void *p = func_name; And for this you need the function to be defined, so just sync our CheckFunctionExistsEx.c with CheckFunctionExists.c from cmake (and later we should drop them out) since it does correct things to detech functions existence. Also for WIN32 there is -FIwinsock2.h -FIws2tcpip.h, and I guess that is not works for mingw gcc (since -F in gcc is framework, and in windows -FI is like -include in gcc). But looks like we do not need them already (due to fixed CheckFunctionExistsEx()). Refs: #605 (cherry picked from commit accf383e044257ecdef002ea255056a5d15a4811) --- cmake/CheckFunctionExistsEx.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/cmake/CheckFunctionExistsEx.c b/cmake/CheckFunctionExistsEx.c index 5ee3e591..224e3404 100644 --- a/cmake/CheckFunctionExistsEx.c +++ b/cmake/CheckFunctionExistsEx.c @@ -1,30 +1,28 @@ #ifdef CHECK_FUNCTION_EXISTS -#ifndef _WIN32 -char CHECK_FUNCTION_EXISTS(); +#ifdef __cplusplus +extern "C" #endif - + char + CHECK_FUNCTION_EXISTS(void); #ifdef __CLASSIC_C__ -int main(){ +int main() +{ int ac; - char*av[]; + char* av[]; #else -int main(int ac, char*av[]){ +int main(int ac, char* av[]) +{ #endif -#ifdef _WIN32 - void * p = &CHECK_FUNCTION_EXISTS; -#else CHECK_FUNCTION_EXISTS(); -#endif - if(ac > 1000) - { + if (ac > 1000) { return *av[0]; - } + } return 0; } -#else /* CHECK_FUNCTION_EXISTS */ +#else /* CHECK_FUNCTION_EXISTS */ -# error "CHECK_FUNCTION_EXISTS has to specify the function" +#error "CHECK_FUNCTION_EXISTS has to specify the function" #endif /* CHECK_FUNCTION_EXISTS */