From: Azat Khuzhin Date: Sun, 22 Apr 2018 22:50:55 +0000 (+0300) Subject: Fix CheckFunctionExistsEx() cmake macro on win32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=accf383e044257ecdef002ea255056a5d15a4811;p=libevent 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 --- 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 */