[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting gated functions w/ AC_CHECK_FUNCS()

From: Nick Bowler
Subject: Re: Detecting gated functions w/ AC_CHECK_FUNCS()
Date: Mon, 2 May 2022 16:49:05 -0400


On 2022-05-02, Philip Prindeville <> 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:

... 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])

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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]