From xemacs-m  Mon Apr 14 02:03:49 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id CAA08271
	for <xemacs-beta@xemacs.org>; Mon, 14 Apr 1997 02:03:47 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id JAA12080; Mon, 14 Apr 1997 09:03:40 +0200 (MET DST)
Sender: hniksic@public.srce.hr
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: build report: 20.1-b15 Linux 2.0.30
References: <199704140501.WAA14466@bittersweet.inetarena.com> 	<m2n2r2rw28.fsf@altair.xemacs.org> 	<kigpvvykv0y.fsf@jagor.srce.hr> <199704140636.XAA19295@bittersweet.inetarena.com>
X-URL: ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/
X-Attribution: Hrv
X-Face: &}4JQk=L;e.~x+|eo]#DGk@x3~ed!.~lZ}YQcYb7f[WL9L'Z*+OyA\nA
        EL1M(".[qvI#a2E6WYI5>>e7'@_)3Ol9p|Nn2wNa/;~06jL*B%tTcn/X
        vhAu7qeES0\|MF%$;sI#yn1+y"
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 14 Apr 1997 09:03:39 +0200
In-Reply-To: "Karl M. Hegbloom"'s message of Sun, 13 Apr 1997 23:36:09 -0700
Message-ID: <kiglo6mkrw4.fsf@jagor.srce.hr>
Lines: 74
X-Mailer: Gnus v5.4.42/XEmacs 19.15

"Karl M. Hegbloom" <karlheg@inetarena.com> writes:

>  > `const-is-losing' should not affect XEmacs stability.  The worst thing
>  > that can happen with `--const-is-losing=no' is for XEmacs not to
>  > compile.
> 
>  It compiles, but gives warnings, like this one
[...]

The story behind this is that const needs to be consistently in a
program.  One const, all const.  The problem is that you can lose if
the compiler's system libraries are not constified properly.  Let's
say you have a function:

int
my_load_file(const char *filename)
{
   if (!strcmp(filename, "/dev/null"))
      ...
   else
      ...
   ...
}

Now, suppose that through a slip in the system, strcmp was misdeclared
as:

int strcmp(char *, const char *);      /* missing const for first arg */

The compiler will generate an ERROR, as filename was const, and could
be "changed" by strcmp.  Of course, as basic a function as strcmp
won't be poluted, but it only makes matters worse.  Sooner or later,
you will stumble on something that breaks your code.  On the other
hand, the win of actually having consts sprinkled around is relatively
low.

Once upon a time Jamie was bitten by this (he even provided an example
to the list), which is why he decided to compile lemacs with
CONST_IS_LOSING by default, which #define-s const to nothing.

Of course, the existing consts were left alone, but the code added
afterwards was no longer consistently constified, which is the source
of the warnings (I'm genuinely surprised that there are no errors!).
Whatever happens, no crashes should ensue from just toggling the value
of const-is-losing.

One can learn quite a bit by browsing the old lists. :-)


P.S.
At the time those decisions were made, I don't think I knew what Emacs
was.

>  This fixes it for me; AFAIK <unistd.h> is on every UNIX computer???
> It's in the POSIX book I haven't finished reading. :-)

It's not.  Please be careful when adding such things.

>   #if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS)
>   #include <stdlib.h>
>   #include <string.h>
> + #include <unistd.h>
>   #endif

Use:

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

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Ask not for whom the <CONTROL-G> tolls.

