Homma Daisuke wrote:
I wrote a program(glut01.sml) that uses GLUT library through Poly/ML's CInterface infrastructure on Mac OS X. But it doesn't work. It aborts with an IOException after "glutDisplayFunc". An execution log(glut-exec.log) and an error message (glut-error.log) are attached.
I thought there are some problems around the callback function. So I wrote 2nd program(glut02.sml). As you see, I changed the "glutDisplayFunc" to accept a function that returns "LONG" (which is wrong by the definition of the original function) instead of "VOID". And it works fine(does not abort).
I had a look at this and it turned out there was a problem with using VOID to return a value from ML to C. I've now fixed this to return zero and it should now work. The updated version is in the CVS repository.
The code actually raised an exception in ML and this showed up a different problem. When an ML callback raises an exception it results in a C++ exception being raised. This ought to work correctly if the callback is called from C++ code and does seem to work when the C code has been compiled with Visual C++ but causes an abort if the code has been compiled with GCC. I'm not sure what the correct behaviour should be if the ML callback function raises an exception rather than returning normally.
David.