On 2020-01-24, Christian Biesinger <cbiesin...@google.com> wrote: > On Fri, Jan 24, 2020 at 8:47 PM Nick Bowler <nbow...@draconx.ca> wrote: >> AC_PROG_CC now tries to select the highest language revision supported >> by the compiler. > > Nice. Is there a way to query what language revision it found, so that > configure scripts can check that it's at least C99 if that's what the > program requires?
The Autoconf philosophy is not to do version checks of any kind. If your program requires certain language features in order to work then the recommended approach is to use AC_COMPILE_IFELSE or similar macros to determine whether those features actually work in the user's compiler. This is important because some compilers claim C99 support but do not actually implement the features you need, and other compilers may have the features you need as extensions but not claim C99 support. For a specific example: Autoconf will detect C99 support in GCC 4.1, but GCC 4.1 does not implement the C99 semantics for "inline". If your program depends on C99 inline, then a simple version check is going to give you an incorrect result. This is why feature tests are preferred in configure scripts. (Of course, Autoconf won't stop you from doing version checks. If for whatever reason you still really really want really want a version test against the C standard revision the compiler claims to implement then I suggest using AC_COMPUTE_INT to determine the value of __STDC_VERSION__). Cheers, Nick