[PD-dev] Win32 - unicode support for files, with public API for externals

IOhannes m zmoelnig zmoelnig at iem.at
Tue Dec 18 18:42:17 CET 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2012-12-18 18:22, Hans-Christoph Steiner wrote:
> /* close a previously opened file this is needed on platforms where
> you cannot open/close resources across dll-boundaries */ int
> sys_close(int fd) { #ifdef _WIN32 return _close(fd); #else return
> close(fd); #endif }

yes, that's how i would do it.
> 
> 
> And leave sys_open, sys_fopen, and sys_fclose as macros in the
> header.  This implementation of sys_open and warning are much more
> complicated.  And tho normally I think its good to avoid #ifdefs in
> headers, in this case I think it actually communicates why we have
> these sys_open/sys_close sys_fopen/sys_fclose in the first place:
> "Win32 lacks good POSIX API support, everything else works as is".
> 

if somebody had to implement sys_fopen() and friends, then i would
understand why you want to minimize the effort, and replace it with
ifdef's.
but check the code: somebody already has implemented sys_fopen(),...
so there is no reason to save labour time.


there could be a very simple way to implement sys_open() without all
the vararg headache. make it:
> int sys_open(const char*name, int flags, mode_t mode);

that is, force the users to always supply the mode.
this would make the header much cleaner (it's clear which arguments
need to be present).

this way, sys_open() would not be 100% compatible with POSIX open().
but afaik the reason for the vararg hell is really, that POSIX decided
to introduce an extra argument to open() at some later point, and did
not want to add yet another function.
open() will happily ignore the 3rd argument if it doesn't need it.


fgmadrs
IOhannes

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlDQqvUACgkQkX2Xpv6ydvQMoACgj6qsuUMpGwPkBatyC0Tvf9UF
lm8Anio5wbFfG0WjPb4CcDU0fgnmaF6z
=bTtX
-----END PGP SIGNATURE-----



More information about the Pd-dev mailing list