Re: [mpich-discuss] [PATCH] config: change PAC_FUNC_NEEDS_DECL to check by assignment
Pavan Balaji <[email protected]> writes:
Eh? My point was that if AC_CHECK_DECLS is doing the same thing as PAC_FUNC_NEEDS_DECL, we might be able to discard that macro totally.
Fair enough, it appears to use the even simpler structure: (void)the_symbol; is perfectly adequate, but cannot be combined with a link test. HWLOC_CHECK_DECL suffers from the same problem. I don't why AC_CHECK_FUNCS appears to be calling HWLOC_CHECK_DECL, but that is the only occurrence of this "int,long,int,long,..." string in either MPICH or autoconf. dnl HWLOC_CHECK_DECL dnl dnl Check declaration of given function by trying to call it with an insane dnl number of arguments (10). Success means the compiler couldn't really check. AC_DEFUN([_HWLOC_CHECK_DECL], [ AC_MSG_CHECKING([whether function $1 is declared]) AC_REQUIRE([AC_PROG_CC]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [AC_INCLUDES_DEFAULT([$4]) $1(int,long,int,long,int,long,int,long,int,long);], [$1(1,2,3,4,5,6,7,8,9,10);])], [AC_MSG_RESULT([no]) $3], [AC_MSG_RESULT([yes]) $2] ) ]) ## clang-3.2 configure:19533: checking for strncasecmp configure:19533: clang -o conftest -O2 -I/home/jed/src/mpich/build-clang/src/mpl/include -I/home/jed/src/mpich/src/mpl/include -I/home/jed/src/mpich/src/openpa/src -I/ home/jed/src/mpich/build-clang/src/openpa/src -I/home/jed/src/mpich/build-clang/src/mpi/romio/include -lnsl conftest.c >&5 conftest.c:142:6: warning: incompatible redeclaration of library function 'strncasecmp' char strncasecmp (); ^ conftest.c:142:6: note: 'strncasecmp' is a builtin with type 'int (const char *, const char *, unsigned long)' 1 warning generated. configure:19533: $? = 0 configure:19533: result: yes configure:19540: checking whether function strncasecmp is declared configure:19555: clang -c -O2 -I/home/jed/src/mpich/build-clang/src/mpl/include -I/home/jed/src/mpich/src/mpl/include -I/home/jed/src/mpich/src/openpa/src -I/home/jed/src/mpich/build-clang/src/openpa/src -I/home/jed/src/mpich/build-clang/src/mpi/romio/include conftest.c >&5 conftest.c:153:2: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] strncasecmp(int,long,int,long,int,long,int,long,int,long); ^~~~~~~~~~~ conftest.c:153:2: warning: incompatible redeclaration of library function 'strncasecmp' /usr/include/string.h:536:12: note: 'strncasecmp' is a builtin with type 'int (const char *, const char *, size_t)' extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) ^ 2 warnings generated. configure:19555: $? = 0 configure:19556: result: no ## gcc configure:19536: checking for strncasecmp configure:19536: gcc -o conftest -O2 -I/home/jed/src/mpich/build-gcc/src/mpl/include -I/home/jed/src/mpich/src/mpl/include -I/home/jed/src/mpich/src/openpa/src -I/home/jed/src/mpich/build-gcc/src/openpa/src -I/home/jed/src/mpich/build-gcc/src/mpi/romio/include -lnsl conftest.c >&5 conftest.c:142:6: warning: conflicting types for built-in function 'strncasecmp' [enabled by default] char strncasecmp (); ^ configure:19536: $? = 0 configure:19536: result: yes configure:19543: checking whether function strncasecmp is declared configure:19558: gcc -c -O2 -I/home/jed/src/mpich/build-gcc/src/mpl/include -I/home/jed/src/mpich/src/mpl/include -I/home/jed/src/mpich/src/openpa/src -I/home/jed/src/mpich/build-gcc/src/openpa/src -I/home/jed/src/mpich/build-gcc/src/mpi/romio/include conftest.c >&5 conftest.c:153:2: warning: data definition has no type or storage class [enabled by default] strncasecmp(int,long,int,long,int,long,int,long,int,long); ^ conftest.c:153:2: error: conflicting types for 'strncasecmp' configure:19558: $? = 1 For the non-builtins, clang gives us the error we expect: configure:20365: checking whether function sched_setaffinity is declared configure:20384: clang -c -O2 -I/home/jed/src/mpich/build-clang/src/mpl/include -I/home/jed/src/mpich/src/mpl/include -I/home/jed/src/mpich/src/openpa/src -I/home/jed/ src/mpich/build-clang/src/openpa/src -I/home/jed/src/mpich/build-clang/src/mpi/romio/include conftest.c >&5 conftest.c:144:9: warning: '_GNU_SOURCE' macro redefined #define _GNU_SOURCE ^ conftest.c:20:9: note: previous definition is here #define _GNU_SOURCE 1 ^ conftest.c:148:2: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] sched_setaffinity(int,long,int,long,int,long,int,long,int,long); ^~~~~~~~~~~~~~~~~ conftest.c:148:2: error: conflicting types for 'sched_setaffinity' /usr/include/sched.h:117:12: note: previous declaration is here extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize, ^ conftest.c:152:25: error: too many arguments to function call, expected 3, have 10 sched_setaffinity(1,2,3,4,5,6,7,8,9,10); ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~ /usr/include/sched.h:117:1: note: 'sched_setaffinity' declared here extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize, ^ 2 warnings and 2 errors generated. configure:20384: $? = 1
participants (1)
-
Jed Brown