Windows FFI patch

"Neil Mitchell" <[email protected]> Wed, 26 Apr 2006 18:55:58 +0100
Newsgroups gmane.comp.lang.haskell.cvs.hugs
Message-ID <404396ef0604261055i325693b6g212ff146af7ed84__19116.8144149289$1146074170$gmane$org@mail.gmail.com>
Hi,

Attached is a patch that is useful (but not essential) for Windows FFI
to work slightly better.

Hugs builds up a command line that it passes to the compiler, for example:

gcc -blah1 <filename> -blah2

In certain compilers -blah2 would not apply to <filename>, as a result
when compiling with MSVC, the use of blah2 after <filename> generates
a warning, but still works. The simple solution is the attached patch
which moves -blah2 before <filename>.

Does this harm gcc? If not then its probably a useful patch. If yes,
then I'll get over it.

There are a few other patches required for FFI - since the command
line used by Hugs in the tree hasn't worked with visual studio
compilers for a long time - I'll commit some patches tonight.

With these tweaks, ffihugs works just great with windows. The only
thing potentially missing is a warning that your carefully written C
file is about to be trashed by ffihugs if you do the "obvious" thing.
Or perhaps hugs should use a different name for the file generates,
like test.temp.hugs.c ? Just anything thats less likely to clash.

Thanks

Neil

_______________________________________________
Cvs-hugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-hugs
windows_ffi.patch (application/octet-stream, 763 B)
Index: src/machdep.c
===================================================================
RCS file: /home/cvs/root/hugs98/src/machdep.c,v
retrieving revision 1.137
diff -u -r1.137 machdep.c
--- src/machdep.c	30 Jan 2006 14:49:25 -0000	1.137
+++ src/machdep.c	26 Apr 2006 17:41:28 -0000
@@ -2354,11 +2354,6 @@
     insertChar('/');
     insert("include\"");
 
-    /* the file to compile */
-    insert(" \"");
-    insert(mkFFIFilename(i));
-    insert("\"");
-
     /* the output file */
     insert(" -o \"");
     insert(mkFFIFilename2(i));
@@ -2370,6 +2365,11 @@
         insert(flags);
     }
 
+    /* the file to compile */
+    insert(" \"");
+    insert(mkFFIFilename(i));
+    insert("\"");
+
 #if 0
     printf("Executing '%s'\n",buffer);
 #endif