[MLton] WideChar

Adam Goode adam@evdebs.org
Fri, 10 Dec 2004 19:21:06 -0500

On Fri, 2004-12-10 at 15:06 -0800, Stephen Weeks wrote:

> > With regard to word8 vs. int8, isn't is a problem either way?  I.e.,
> > does the FFI support unsigned char?  
> The FFI supports unsigned char via the SML type Word8.word.  See
> 	http://mlton.org/ForeignFunctionInterfaceTypes
> > If so then that should be word8 while char should be int8 
> Yes, that's what we do.

There seems to be a problem here, since I think in C, "char" can be
either "signed char" or "unsigned char". GCC provides the -fsigned-char
and -funsigned-char options.

>From the GCC info page:

     Let the type `char' be unsigned, like `unsigned char'.

     Each kind of machine has a default for what `char' should be.  It
     is either like `unsigned char' by default or like `signed char' by

     Ideally, a portable program should always use `signed char' or
     `unsigned char' when it depends on the signedness of an object.
     But many programs have been written to use plain `char' and expect
     it to be signed, or expect it to be unsigned, depending on the
     machines they were written for.  This option, and its inverse, let
     you make such a program work with the opposite default.

     The type `char' is always a distinct type from each of `signed
     char' or `unsigned char', even though its behavior is always just
     like one of those two.


I'm pretty sure that x86 defaults to signed char, while PowerPC defaults
to unsigned char. Makes for some interesting portability issues

Is this accounted for in the MLton FFI?