Re: tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

Nick Bowler <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.general,gmane.comp.compilers.tinycc.devel
Message-ID <CADyTPEw7Uhs__m3rqNTDEzKXeP3TZSiYGFKa0ea4oQaHO7dorQ@mail.gmail.com>
On 2023-09-23, Nick Bowler <[email protected]> wrote:
> On 2023-09-23, Detlef Riekenberg <[email protected]> wrote:
>> AC_CHECK_DEFINE(__unix, CFLAGS="-DFOUND__unix $CFLAGS")
>> AC_CHECK_DEFINE(__unix__, CFLAGS="-DFOUND__unix__ $CFLAGS")
>> AC_CHECK_DEFINE(__linux__, CFLAGS="-DFOUND__linux__ $CFLAGS")
[...]
> So it sounds like there must be some third party code involved which
> is defining this macro (and this code is defining macros in the AC_*
> namespace to make it look like it came from Autoconf when in fact it
> did not).

Just to add, you don't need any third party macros to check for typical
C predefined macros including __unix, etc.  I would write such checks
something like this (untested):

  AC_COMPUTE_INT([unix_val], [__unix], [@&t@], [unix_val=0])
  AS_IF([test $unix_val -ne 0],
    [put code here to run when __unix is defined and is non-zero])

That works out of the box with Autoconf and should be a very robust
check.  The third argument to AC_COMPUTE_INT is @&t@ to prevent
Autoconf from inserting the default #includes in the test program.

If you need to distinguish the case where __unix may be pre-defined
with the value 0 (probably not relevant with this particular macro),
then you can tweak the action-if-failed (fourth argument) and if
condition a bit.

Hope that helps,
  Nick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.