Hi, On 2022-05-02, Philip Prindeville <philipp_subx@xxxxxxxxxxxxxxxxxxxxx> wrote: > I was wondering how to do discovery of functions like open_memstream() which > is only exposed by <features.h> when compilation used -D_GNU_SOURCE or > -D_POSIX_C_SOURCE=200809L. The "normal way" is to just use the AC_USE_SYSTEM_EXTENSIONS macro early in your configure script which simply tries to turn every extended C library function on. Then you can simply not care at all about these macros that are only really important when you are writing a compiler test suites. That being said... [...] > How do I bracket a particular AC_CHECK_FUNCS() invocation with defines that > might be critical? > > I tried using: > > save_CFLAGS="$CFLAGS" > CFLAGS="CFLAGS -D_POSIX_C_SOURCE=200809L" ... the idea is right but this assignment has a typo: it is adding the literal string "CFLAGS" to the compiler command line, probably causing subsequent compiler invocation to fail (and the test will probably not return usable results). > AC_CHECK_FUNCS([open_memstream]) > CFLAGS="$save_CFLAGS" Note that AC_CHECK_FUNCS caches the result so it cannot easily be used in this manner if you want to check the same function multiple times (e.g., to probe different settings for CPPFLAGS). If this is a problem you can use AC_LINK_IFELSE instead. Hope that helps, Nick