Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2002:
[Freeciv-Dev] Re: gcc poisoning
Home

[Freeciv-Dev] Re: gcc poisoning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: gcc poisoning
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Thu, 24 Oct 2002 20:55:56 +0200

On Thu, Oct 24, 2002 at 02:51:55PM +0000, Per I. Mathisen wrote:
> For gcc > 3 you may "poison" certain non-portable functions so that they
> are not used. If we want to use this, we must add a check for #pragma gcc
> poison to autoconf and such, but for now, I've added gcc poisoning in the
> attached patch, and done the necessary rearrangements for it to work (some
> basic header sanity, like ensuring we don't call system headers with our
> defines). All I found of non-portable function use was two strerror(),
> however.
> 
> So basically I want you to chime in if you think gcc poisoning is
> something worth putting in, and then I'll do the required autoconf work.

Why autoconf work?

> We may want to include the attached header sanitation anyway, maybe.

Lets see.

>        freelog(LOG_NORMAL, "error in select() return=%d errno=%d (%s)",
> -           n, errno, strerror(errno));
> +           n, errno, mystrerror(errno));
>        return -1;
>      }

Ok anyway.

> Index: common/netintf.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/common/netintf.c,v
> retrieving revision 1.13
> diff -u -r1.13 netintf.c
> --- common/netintf.c  2002/03/05 15:46:22     1.13
> +++ common/netintf.c  2002/10/24 14:46:20
> @@ -23,6 +23,9 @@
>  #include <signal.h>
>  #include <string.h>

> +#ifdef HAVE_UNISTD_H
> +#include <unistd.h>
> +#endif

These ifdef guards are also missing also in other places:

./client/agents/cma_core.c:20:#include <unistd.h>
./client/audio_esd.c:20:#include <unistd.h>             /* close */
./client/packhand.c:23:#include <unistd.h>
./client/gui-beos/lib/Bdh/BdhApp.cpp:6:#include <unistd.h>
./common/support.c:52:#include <unistd.h>

> -#include "shared.h"          /* TRUE, FALSE */
> -#include "support.h"

/me is always for reducing the interfile dependencies.

>       freelog(LOG_ERROR, _("Could not read data directory %s: %s."),
> -             dirs[dir_num], strerror(errno));
> +             dirs[dir_num], mystrerror(errno));

Ok anyway.

> +/* Poison functions to prevent them from being used (portability) */
> +#pragma GCC poison snprintf vsnprintf strcasecmp strncasecmp usleep
> +#pragma GCC poison strerror gethostname

What does an old gcc thinks about these?

> -#include "netintf.h"
> +/* #include "netintf.h"*/

??

> -#include "shared.h"          /* bool type and fc__attribute */
> +/* Want to use GCC's __attribute__ keyword to check variadic
> + * parameters to printf-like functions, without upsetting other
> + * compilers: put any required defines magic here.
> + * If other compilers have something equivalent, could also
> + * work that out here.   Should this use configure stuff somehow?
> + * --dwp
> + */
> +#if defined(__GNUC__)
> +#define fc__attribute(x)  __attribute__(x)
> +#else
> +#define fc__attribute(x)
> +#endif
> +
> +typedef int bool;

Here were are in a philosophical discussion whether these are features
which we are missing on some systems (support) or freeciv-specific
features (shared).

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  Tank: So what do you need? Besides a miracle.
  Neo: Guns. Lots of guns.
    -- From The Matrix


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