You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 525 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
ocamlc -output-obj does not work well on WIN2000, especially with Unix
calls.
For example, the code below allows a C program (yy.c) to call
an ML function (in xx.ml). This call should print out the hostname
of the machine, the result is junk.
Any help would be appreciated. I'm also having various other problems
with code created by -output-obj on WIN2000, perhaps this will solve them
as well.
Thanks,
Ohad.
-------- File xx.ml -------------------------------------------------
open Printf
let c_hostname () =
let h = Unix.gethostname () in
printf "hostname=%s\n" h; flush stdout;
()
let _ =
Callback.register "c_hostname_v" c_hostname ;
()
My apologies for this late answer, I forgot about your message and
it's only now that I'm going over the open bug reports.
For example, the code below allows a C program (yy.c) to call
an ML function (in xx.ml). This call should print out the hostname
of the machine, the result is junk.
As it turns out, the problem is not specific to Windows, and affects
all uses of -output-obj. Briefly, the Caml initialization code terminates
by calling the functions registered by at_exit. Under Windows, Unix
registers one such function that shuts down the Winsock library.
Hence, when caml_startup returns, Winsock is no longer operational
and calls to Winsock functions (through Caml functions or directly)
fail.
This will be fixed in 3.03 by not calling at_exit functions if
-output-obj is specified. In the meantime, you can change
the following line in otherlibs/win32unix/unix.ml
Original bug ID: 525
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Ohad Rodeh
Version: 3.02
OS: WIN2000
Submission from: gvul.haifa.il.ibm.com (192.115.216.67)
ocamlc -output-obj does not work well on WIN2000, especially with Unix
calls.
For example, the code below allows a C program (yy.c) to call
an ML function (in xx.ml). This call should print out the hostname
of the machine, the result is junk.
Any help would be appreciated. I'm also having various other problems
with code created by -output-obj on WIN2000, perhaps this will solve them
as well.
Thanks,
Ohad.
-------- File xx.ml -------------------------------------------------
open Printf
let c_hostname () =
let h = Unix.gethostname () in
printf "hostname=%s\n" h; flush stdout;
()
let _ =
Callback.register "c_hostname_v" c_hostname ;
()
--------- File yy.c -------------------------------------------------
#include "caml/mlvalues.h"
#include "caml/memory.h"
#include "caml/callback.h"
#include "caml/alloc.h"
#include "caml/config.h"
value *c_hostname_v = NULL;
int main (int argc, char *argv){
caml_startup(argv) ;
c_hostname_v = caml_named_value((char) "c_hostname_v");
callback(*c_hostname_v, Val_unit);
}
--------- Makefile.nt -----------------------------------------------
CC = cl /nologo /Ox /MT /W3 /I$(CAMLLIB)
LIBSYSCL = -link /NODEFAULTLIB
ADVAPI32.lib
LIBCMT.lib
OLDNAMES.lib
KERNEL32.lib
WSOCK32.lib
##
.SUFFIXES: .ml .cmo .cmx .mli .cmi .c .o .obj .cmx
.mli.cmi:
ocamlc -c $< -o $@
.ml.cmo:
ocamlc -c $< -o $@
.ml.cmx:
ocamlopt -c $< -o $@
.c.o :
$(CC) -c $(CFLAGS) $< -o $@
.c.obj :
$(CC) -c $(CFLAGS) $< -o $@
##
all : zz.exe #xx.exe
xx.exe: xx.cmo
ocamlc -custom -o xx.exe unix.cma xx.cmo
zz.obj : xx.cmo
ocamlc -output-obj -o zz.obj unix.cma xx.cmo
zz.exe : zz.obj yy.obj xx.cmo
$(CC) -o zz.exe yy.obj zz.obj
$(CAMLLIB)\libunix.lib
$(CAMLLIB)\libcamlrun.lib
$(LIBSYSCL)
clean :
-del /Q*.obj *.exe .cm
The text was updated successfully, but these errors were encountered: