[mtasc] PATCH: Mac OS X executable path (RE: Problems On OS X)
Bob Ippolito
bob at redivi.com
Sun Mar 13 10:36:05 CET 2005
New to the list, but I've just scanned over most of the archives and
saw a problem that I could solve...
By the way, what's the best way to recompile? Currently I have just
edited install.ml and turned off the CVS stuff, but is there a quicker
way? I'm new to OCaml, so I'm not familiar with the workflow.
Below is a patch to fix the issue on OS X where it can not find the
compiler's executable path:
Index: extc/extc_stubs.c
===================================================================
RCS file: /cvsroot/ocaml/extc/extc_stubs.c,v
retrieving revision 1.5
diff -u -r1.5 extc_stubs.c
--- extc/extc_stubs.c 26 Jan 2005 16:23:11 -0000 1.5
+++ extc/extc_stubs.c 13 Mar 2005 09:32:33 -0000
@@ -26,6 +26,10 @@
#else
# include <unistd.h>
#endif
+#if defined(__APPLE__)
+#include <sys/param.h>
+#include <mach-o/dyld.h>
+#endif
#define zval(z) ((z_streamp)(z))
@@ -119,9 +123,15 @@
}
CAMLprim value executable_path(value p) {
-#ifdef _WIN32
+#if defined(_WIN32)
char path[MAX_PATH];
if( GetModuleFileName(NULL,path,MAX_PATH) == 0 )
+ failwith("executable_path");
+ return caml_copy_string(path);
+#elif defined(__APPLE__)
+ char path[MAXPATHLEN+1];
+ unsigned long path_len = MAXPATHLEN;
+ if ( _NSGetExecutablePath(path, &path_len) )
failwith("executable_path");
return caml_copy_string(path);
#else
More information about the mtasc
mailing list