kfl / mosml

Moscow ML is a light-weight implementation of Standard ML (SML), a strict functional language widely used in teaching and research.
http://mosml.org
341 stars 42 forks source link

Add some missing headers #72

Open barracuda156 opened 1 year ago

barracuda156 commented 1 year ago

This is to partly address this failure: https://github.com/kfl/mosml/issues/71 It seems that these headers were simply forgotten here, since other files add them when related functions are used.

barracuda156 commented 1 year ago

Hmm, with mpq.c does not work as supposed. Without the header GCC complains:

make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_mosml/mosml-dynlibs/work/mosml-13c581aec46eea134e478f2e2b6456278e36ecce/src/dynlibs/mpq'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_mosml/mosml-dynlibs/work/compwrap/cc/opt/local/bin/gcc-mp-12 -Dunix -O2 -fno-defer-pop -fPIC -I/opt/local/include/mosml -I /opt/local/include/postgresql14 -c -o mpq.o mpq.c
In file included from mpq.c:8:
mpq.c: In function 'pq_getbool':
mpq.c:348:20: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
  348 |   return Val_bool(!strcmp(v, "t"));
      |                    ^~~~~~
/opt/local/include/mosml/mlvalues.h:98:45: note: in definition of macro 'Val_hp'
   98 | #define Val_hp(hp) ((value) (((header_t *) (hp)) + 1))
      |                                             ^~
/opt/local/include/mosml/mlvalues.h:241:21: note: in expansion of macro 'Atom'
  241 | #define Val_bool(x) Atom((x) != 0)
      |                     ^~~~
mpq.c:348:10: note: in expansion of macro 'Val_bool'
  348 |   return Val_bool(!strcmp(v, "t"));
      |          ^~~~~~~~
mpq.c:21:1: note: include '<string.h>' or provide a declaration of 'strcmp'
   20 | #include "libpq-fe.h"
  +++ |+#include <string.h>
   21 | 
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_mosml/mosml-dynlibs/work/compwrap/cc/opt/local/bin/gcc-mp-12 -Wl,-rpath,/opt/local/lib/mosml -bundle -undefined dynamic_lookup -lcrypto -o libmpq.so mpq.o /opt/local/lib/postgresql14/libpq.a

However if the header is added, it fails:

make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_mosml/mosml-dynlibs/work/mosml-13c581aec46eea134e478f2e2b6456278e36ecce/src/dynlibs/mpq'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_mosml/mosml-dynlibs/work/compwrap/cc/opt/local/bin/gcc-mp-12 -Dunix -O2 -fno-defer-pop -fPIC -I/opt/local/include/mosml -I /opt/local/include/postgresql14 -c -o mpq.o mpq.c
In file included from /opt/local/include/mosml/mlvalues.h:5,
                 from mpq.c:8:
/opt/local/include/mosml/config.h:23:36: error: expected declaration specifiers or '...' before '(' token
   23 | #define bcopy(src,dst,len) memmove((dst), (src), (len))
      |                                    ^
/opt/local/include/mosml/config.h:23:43: error: expected declaration specifiers or '...' before '(' token
   23 | #define bcopy(src,dst,len) memmove((dst), (src), (len))
      |                                           ^
/opt/local/include/mosml/config.h:23:50: error: expected declaration specifiers or '...' before '(' token
   23 | #define bcopy(src,dst,len) memmove((dst), (src), (len))
      |                                                  ^
make[1]: *** [mpq.o] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_mosml/mosml-dynlibs/work/mosml-13c581aec46eea134e478f2e2b6456278e36ecce/src/dynlibs/mpq'
barracuda156 commented 1 year ago

For now, I have dropped the change from mpq.c. It leaves the bug there, but since adding header creates a conflict, something else should be done.

Other ones work neatly.

barracuda156 commented 1 year ago

@kfl Could you review this, please?