wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
313 stars 26 forks source link

Compiling on Cygwin64: print.c:66:14: error: conflicting types for ‘utoa’ #11

Open mogria opened 9 years ago

mogria commented 9 years ago

I tried to compile es on cygwin (64bit) by using the tarball for the 0.9 release. I configured the source (from an other build directory) and ran make:

[...]
gcc  -I. -I../es-0.9 -g -O2   -c -o prim-sys.o ../es-0.9/prim-sys.c
gcc  -I. -I../es-0.9 -g -O2   -c -o prim.o ../es-0.9/prim.c
gcc  -I. -I../es-0.9 -g -O2   -c -o print.o ../es-0.9/print.c
../es-0.9/print.c:66:14: error: conflicting types for ‘utoa’
 static char *utoa(unsigned long u, char *t, unsigned int radix, char *digit) {
              ^
In file included from /usr/include/sys/unistd.h:8:0,
                 from /usr/include/unistd.h:4,
                 from ../es-0.9/stdenv.h:24,
                 from ../es-0.9/es.h:4,
                 from ../es-0.9/print.c:3:
/usr/include/stdlib.h:184:8: note: previous declaration of ‘utoa’ was here
 char * _EXFUN(utoa,(unsigned, char *, int));
        ^
<builtin>: recipe for target 'print.o' failed
make: *** [print.o] Error 1
$ 

It seems that the function utoa defined in print.c clashes with a function of the same name defined in stdlib.h.

$ grep -r 'utoa' .                                                  /opt/es-0.9
./print.c:static char *utoa(unsigned long u, char *t, unsigned int radix, char *digit) {
./print.c:              t = utoa(u / radix, t, radix, digit);
./print.c:      len = utoa(u, number, radix, table[upper]) - number;

This function is only used two times. Let's just rename it?

$ sed -ri 's/utoa/another_utoa/g' **/**.c                           /opt/es-0.9
$ grep -r 'utoa' .                                                  /opt/es-0.9
./print.c:static char *another_utoa(unsigned long u, char *t, unsigned int radix, char *digit) {
./print.c:              t = another_utoa(u / radix, t, radix, digit);
./print.c:      len = another_utoa(u, number, radix, table[upper]) - number;

I could now compile the es from the source directory by using ./configure && make. (I needed to install the bison package)