[MLton] bool and MLton FFI
   
    Wesley W. Terpstra
     
    wesley@terpstra.ca
       
    Fri, 23 Jun 2006 16:58:36 +0200
    
    
  
On Jun 23, 2006, at 4:33 PM, skaller wrote:
> On Fri, 2006-06-23 at 14:27 +0200, Wesley W. Terpstra wrote:
>> I disagree here. We should start encouraging users to use _import
>> like this:
>> 	_import "foo" : C_Int.t * C_Long.t * Int32.t-> C_Bool.t
>> for the function:
>> 	extern bool foo(int x, long y, int32_t z);
>> Otherwise their code won't be portable.
>
> This is naive. No realistic libraries provide functions like that.
That is untrue. Lots do. Especially small-scale user libraries which  
are exactly the situation where you want to use the FFI directly.
> Real library API's look like:
> 	GLint GLgetStatus(GLint);
There is some typedef for GLint; obviously, that's what you would use.
ie: map 'typedef int GLint' to 'type GLint = C_Int.int'
> 	#if _WIN32
> 	#type GLint = int
> 	#endif
I'm going to assume by the above you mean something like:
	#ifdef X
	typedef int GLint;
	#else
	typedef long GLint;
	#endif
In this case, use the mlnlffigen. We aren't responsible for parsing C  
header files in the FFI.