Ha! Ha! _read and _write aren’t binary!

6:05 pm Erlang

… which screws you nicely for a while, while you’re trying to figure out what’s broken in your erlang port. Unfortunately, there doesn’t seem to be a portable solution. That said, here’s what you do in naively configured unhosted from-unix toolchains (eg DevKitPro):

freopen(NULL, "wb", stdin);
freopen(NULL, "wb", stdout);

And, in Windows:

_setmode( _fileno( stdin ) , _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY );

That should save you some pain.

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.