RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm-5_1: rpm/rpmio/ argv.h

From: Ralf S. Engelschall <rse+rpm-devel@rpm5.org>
Date: Tue 29 Jul 2008 - 20:47:01 CEST
Message-ID: <20080729184701.GA39824@engelschall.com>
On Tue, Jul 29, 2008, Arkadiusz Miskiewicz wrote:

> On Tuesday 29 July 2008, Ralf S. Engelschall wrote:
>
> > >     */
> > >
> > >   +#include <stdint.h>
> > >   +
> > >    typedef    const char * ARGstr_t;
> > >    typedef ARGstr_t * ARGV_t;
> > > [...]
> >
> > Even if we are already in 2008, unconditionally including the C99
> > header <stdint.h> is not recommended as it breaks platform portability.
> > We really have to wrap this. If you want to externally include this
> > "argv.h" outside the RPM source tree one really has to supply #defines
> > to enable those includes.
>
> I think that we should wrap crappy old platforms and don't punish modern one
> (not vice versa).
>
> So AC_PROG_CC_C99 in configure.ac
>
> if x = xno; then
>  AC_DEFINE(MY_COMPILER_IS_A_CRAP)
> fi
>
> and
> #ifndef MY_COMPILER_IS_A_CRAP
> #include <stdint.h>
> #endif
>
> type of solution. Does that work for you?

In general I'm ok with an approach which punishes only
old/obsolete/deprecated/whatever platforms. But in this case I'm more
thinking about neither distinguishing between old and new and more about
mostly feature based testing:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if defined(HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__+0 >= 199901L)
#include <stdint.h>
#endif
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#endif

This boils down to your simple #include if nothing is explicitly defined
(usually outside the RPM source tree), but if one has Autoconf macros
in place (the case inside the RPM source tree) we can still compile on
older platforms.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
Received on Tue Jul 29 20:50:09 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.