Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: numeric brace expansion



On undefining HAVE_STRTOL on machines that do have strtol():

mcampbel@xxxxxxxxxxxxxxxx wrote:
> gcc -c -I.. -I. -I. -DCONFIG_BROKETS -DHAVE_CONFIG_H -Wall -Wno-implicit -Wmi
> ssing-prototypes -O2 builtin.c
> In file included from zsh.h:1013,
>                  from builtin.c:32:
> prototypes.h:125: conflicting types for `strtol'
> /optware/unsupported/lib/gcc-lib/sparc-sun-solaris2.3/2.6.3/include/stdlib.h:
> 75: previous declaration of `strtol'
> *** Error code 1
> make: Fatal error: Command failed for target `builtin.o'
> Current working directory /export/local/ftp/zsh-2.6-beta9/Src
> *** Error code 1

You should be able to fix this just by altering prototypes.h and
compat.c to add a `const' to the first argument of strtol(), which is
what gcc is worried about: it doesn't really care if the const is
there or not, but if it is in one prototype it needs to be there in
any other.  I think the following is the ANSI/ISO prototype anyway,
but it looks like the zsh code avoids using `const' in prototypes
probably to avoid breaking older compilers.  Does ansi2knr not handle
const's?  We could always do the

#ifdef __STDC__
#define CONST const
#else
#define CONST
#endif

trick.

*** Src/prototypes.h~	Wed May 31 05:09:46 1995
--- Src/prototypes.h	Tue Jun  6 10:32:32 1995
***************
*** 122,128 ****
  /**************************************************/
  /*** prototypes for functions built in compat.c ***/
  #ifndef HAVE_STRTOL
! extern long strtol _((char *s, char **t, int base));
  #endif
  
  #ifndef HAVE_STRSTR
--- 122,128 ----
  /**************************************************/
  /*** prototypes for functions built in compat.c ***/
  #ifndef HAVE_STRTOL
! extern long strtol _((const char *s, char **t, int base));
  #endif
  
  #ifndef HAVE_STRSTR
*** Src/compat.c~	Wed May 31 05:10:08 1995
--- Src/compat.c	Tue Jun  6 10:35:14 1995
***************
*** 35,41 ****
  
  #ifndef HAVE_STRTOL
  long
! strtol(char *s, char **t, int base)
  {
      long ret = 0;
  
--- 35,41 ----
  
  #ifndef HAVE_STRTOL
  long
! strtol(const char *s, char **t, int base)
  {
      long ret = 0;
  

-- 
Peter Stephenson <P.Stephenson@xxxxxxxxxxxxx>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.



Messages sorted by: Reverse Date, Date, Thread, Author