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: Sun, 07 Jul 2002 16:15:34 -0500

Thank you for your reply.

It appears we have different viewpoints of what needs a rationale.  I,
and a substantial portion of the C++ programming community, tend to
take what may be termed a minimalist view:  why should I have to pay
for a feature I don't want and have no need for?  Others, at least in
the autoconf world, it appears, regard the use of exit() as so
fundamental that they are always willing to pay for it, and to force
others to do so, as well.

If autoconf is truly to support C++ among its list of programming
languages, then I believe that it is important to do so in a manner
that is consistent with the C++ programming philosophy.  I
respectfully urge reconsideration of the underlying philosophy.

Regarding your suggestion to use <cstdlib>, I have already pointed out
that it leads to the same problem for me.  Forcing implicit inclusion
of any header, whether <stdlib.h>, <cstdlib>, or anything else,
immediately causes my test programs to fail.  The whole point of
autoconf is to sniff out an environment; therefore, I won't
artificially change my environment (and certainly could not change
that of my users) just to cater to autoconf.

Further, what if I want to write my own function named exit()?  Or
rand()?  Or ...?  Why am I artificially prohibited from doing so?

Re unwieldly:  maybe/maybe not.  As stated, I was trying to
accommodate backward compatibility.  I'd be much happier if I didn't
have to, but (as I said before) I'm willing to adapt.  But I need some
way to do so.

You wrote, in part:
    Yes, you can use "return foo;" in the main() function.
    But, why not 'exit()'?
I would reply:
    Yes, you can use "exit(foo);" in the main() function.
    But, why not 'return foo'?

I grant that autoconf maintainers have the right to release their
product in the manner that seems best to them.  I am merely trying to
point out that the status quo causes significant difficulties, does so
in a manner that appears to be undocumented (i.e., the implicit
support for exit), has no rationale, and runs counter to a fundamental
C++ programming philosophy.

All the C++ programmers I know are perfectly capable of inserting
#include <stdlib.h> where they need it.  They also avoid the inclusion
of unused headers.  I'd sincerely like autoconf to support us in this
style.

Best,

    - WEB



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


> "Walter E. Brown" <address@hidden> writes:
>
> > harinath wrote:
>
> >> ... the loop in _AC_PROG_CXX_EXIT_DECLARATION
> >>
> >>   for ac_declaration in \
> >>    ''\
> >>    '#include <stdlib.h>' \
> [snip]
> >> This whole section is necessary since AC_LANG_PROGRAM supports
the
> >> use of exit() in C/C++ program test fragments.
> >
> > 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.
>
> In my view, you would have to provide a rationale for _not_
providing
> support for exit().  Yes, you can use "return foo;" in the main()
> function.  But, why not 'exit()'?
>
> > 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.
>
> Both seem unweildly.  You'll need to provide more reasons why this
is
> essential: especially if we use my other suggestion to try <cstdlib>
> first.
>
> If you are so concerned with this, you should put
>
>   m4_define([_AC_PROG_CXX_EXIT_DECLARATION],[])
>
> somewhere early in your configure.in and be done with it.
>
> > 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!
>
> It seems the right thing is to invoke configure with the right
> directories listed in CXXFLAGS so that it picks up the correct
> headers.  You can even create a directory with a dummy stdlib.h
> that contains only an #error, and put that ahead in your include
> search path.
>
> - Hari
> --
> Raja R Harinath ------------------------------ address@hidden
>




reply via email to

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