autoconf
[Top][All Lists]
Advanced

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

Re: Contents of <confdefs.h> for C++


From: Walter E. Brown
Subject: Re: Contents of <confdefs.h> for C++
Date: Fri, 05 Jul 2002 17:26:55 -0500

Ah, we're making progress; thank you!  This is the first I've heard
that "AC_LANG_PROGRAM supports the use of exit() in C/C++ program test
fragments" -- I haven't found any documentation to this effect.  Does
anyone know the rationale for this decision?  If so, let's please
ensure it's written down somewhere.

More to the point:  Assuming this feature is indeed an autoconf
requirement, could its logic be encapsulated so that test programs
that want or need to call exit() can enable this feature?  I can
imagine, for example, requiring such a test program to contain the
equivalent of:

    #define I_NEED_TO_CALL_EXIT

so that <confdefs.h> could be expressed:

    #if defined(__cplusplus)  &&  defined(I_NEED_TO_CALL_EXIT)
      #include <stdlib.h>
    #endif

Perhaps negative logic would be preferable for reasons of backward
compatibility:

    #if defined(__cplusplus)  &&  ! defined(I_DONT_NEED_TO_CALL_EXIT)
      #include <stdlib.h>
    #endif

I could adapt to either.

In any case, I can't live with the status quo, since even my little
tests require complete control over headers that are included.  (Since
the search paths in our environment are non-standard, all of my little
tests are innocently being given the wrong <stdlib.h> -- when they
really don't need any such header!  The suggested alternative
involving <cstdlib> seems reasonable, but really doesn't change the
situation for me.)  For now, I guess I'm going to avoid <confdefs.h>
and try to write my actions so as to produce my own equivalent to
<confdefs.h> -- does this seem feasible?

Thanks again.

    - WEB


----- Original Message -----
From: "Raja R Harinath" <address@hidden>
To: "Paul Eggert" <address@hidden>
Cc: <address@hidden>; <address@hidden>
Sent: Friday, July 05, 2002 3:31 PM
Subject: Re: Contents of <confdefs.h> for C++


> Hi,
>
> Paul Eggert <address@hidden> writes:
>
> >> Date: Fri, 05 Jul 2002 10:40:17 -0500
> >> From: "Walter E. Brown" <address@hidden>
> >>
> >> Thanks, Paul, for the courteous and quick response.
> >>
> >> Suppose my program defines entities whose names clash with names
> >> declared in <stdlib.h>.
> >
> > That's certainly reasonable, but we're not talking about your
actual
> > program here.  We're talking about what the little test program --
the
> > one that "configure" compiles.  Surely this little test program
can be
> > written so that it will still work as desired even if <stdlib.h>
is
> > included.
>
> Yep.  The program itself will/should never see 'confdefs.h', which
> should be deleted once 'configure' is done.
>
> Also, any fragment in 'configure.in' is basically testing for
> portability (and/or lack of portability :-) -- so it must be quite
> tolerant (or quite intolerant so that problems are found quickly).
>
> >> However, there may be compelling reasons for autoconf's current
> >> behavior
> >
> > If you find them out, please let me know.  Like I said, I don't
use
> > C++, so I'm not the right guy to ask.  It would be helpful if this
> > stuff were written down as comments in the source.
>
> I guess the loop in _AC_PROG_CXX_EXIT_DECLARATION
>
>   for ac_declaration in \
>    ''\
>    '#include <stdlib.h>' \
>    'extern "C" void std::exit (int) throw (); using std::exit;' \
>    'extern "C" void std::exit (int); using std::exit;' \
>    'extern "C" void exit (int) throw ();' \
>    'extern "C" void exit (int);' \
>    'void exit (int);'
>
> could use one more alternative:
>
>    '#include <cstdlib>
>    using std::exit;'
>
> before the '#include <stdlib.h>' line.
>
> This whole section is necessary since AC_LANG_PROGRAM supports the
> use of exit() in C/C++ program test fragments.
>
> - Hari
> --
> Raja R Harinath ------------------------------ address@hidden
>




reply via email to

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