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: 490 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
let _ =
print_tring "Starting-1\n"; flush stdout;
()
When file xx.obj is linked with yy.cmo, the only the line:
"Starting-1\n" is printed, the next line is not. However, if
I use caml_startup instead (with the appropriate compilation sequence,
things work fine.
The caml_main(char **argv) function does not work properly, it fails to
return control to the C-code that calls it.
For example:
[...]
int main (char **argv, int argc){
[...]
This should be int main(int argc, char ** argv).
With this correction, the code works as expected under Unix. However,
under Windows, your "main" function is never called -- this can be
checked easily by printing a message before calling caml_main(argv).
I believe this is due to difference in linking semantics. The OCaml
runtime library (libcamlrun) contains a default definition of "main"
(as a call to caml_main()). Under Unix, a user-provided definition of
"main" overrides that given in the library, because the library is
linked after the user code. It seems that Windows works differently,
picking the last definition of "main" (i.e. that in libcamlrun)
instead of the first. I'm not sure this can be fixed easily, but I'll
have a look at it.
Close examination reveals that bytecode executable wasn't linked with -custom,
hence user-provided main() function is ignored. Could deserve a warning, but is
not a bug.
Original bug ID: 490
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Ohad Rodeh
Version: 3.02
OS: WIN2000
Submission from: sungold1.il.ibm.com (192.116.181.41)
The caml_main(char **argv) function does not work properly, it fails to
return control to the C-code that calls it.
For example:
----------------------------- xx.c ------------------
#include "caml/mlvalues.h"
#include "caml/memory.h"
#include "caml/callback.h"
#include "caml/alloc.h"
#include <stdio.h>
int main (char **argv, int argc){
// caml_startup(argv);
caml_main(argv);
printf ("Hi, after caml-main"); fflush(stdout);
}
----------------------------- yy.ml ------------------
let _ =
print_tring "Starting-1\n"; flush stdout;
()
When file xx.obj is linked with yy.cmo, the only the line:
"Starting-1\n" is printed, the next line is not. However, if
I use caml_startup instead (with the appropriate compilation sequence,
things work fine.
The compilation script is as follows:
CFLAGS = /Ox /MT /W3 /I$(CAMLLIB)
.SUFFIXES: .cmo .ml .c .obj$(CFLAGS) -c $ <
.ml.cmo:
ocamlc -c $<
.c.obj:
cl /nologo
all : caml-startup
caml-main: xx.obj yy.cmo
ocamlc -o xx.exe xx.obj yy.cmo
caml-startup: xx.exe
yy.obj : yy.cmo
ocamlc -output-obj -o yy.obj yy.cmo
xx.exe : xx.obj yy.obj
cl /nologo -o xx.exe
xx.obj yy.obj
$(CAMLLIB)\libcamlrun.lib
clean:
-del /Q *.obj *.exe .cm core *.lib
force : clean all
The text was updated successfully, but these errors were encountered: