Search code examples
glibcautoconf

autoconf: Detect deprecated functions (in Glibc)


Is there a way for Autotools to test a given function is deprecated in GNU libc?

I've been using AC_CHECK_FUNCS(readdir_r) to test whether a system has readdir_r() or not. But now, since GNU Libc 2.24, readdir_r() is deprecated, I'd like to use readdir() on those system.

Does autoconf have a macro to test a give function is deprecated or not? If not, what is the best way to handle this?

I know that newer GCC with -Wdeprecated-declarations prints a warning. But what I'm looking for is to find deprecated function at configure time so that I can use the recommended function instead.


Solution

  • Not easily, because AC_CHECK_FUNCS checks whether the function is available at link time. What you could do would be to use attribute.m4 (as shipped with, say, systemd), use CC_CHECK_WERROR, CC_CHECK_FLAGS_APPEND with -Wdeprecated-declarations and then use AC_COMPILE_IFELSE to figure out whether the whole thing compiles.