[Issue 8642] Fix `fopen` and friends signatures on Windows to not accept `char*`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 11 15:12:58 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8642



--- Comment #7 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-09-11 15:13:21 PDT ---
> `char` is UTF-8 codepoint in D. It is specified and there is no choice. And you know it. So I don't understand your comment.

Yes. But it's expected to use char when dealing with C's char. Any necessary
conversion should be done at the call site. At most what you'd do is make C
signature's take ubyte instead of char, which would cause all kinds of
confusion.

Yes. You need to be careful when passing strings to C functions which take
char, because Microsoft was stupid, and ideally you'd use the w* functions on
Windows precisely because of this nonsense, but that's something that the
programmer needs to know and handle appropriately. The function signature
itself is fine. Making it ubyte wouldn't solve anything, and you'd basically be
arguing that ubyte should always be used instead of char in C bindings, and I
don't think that you're going to find much traction on that.

Another thing to remember is that we currently use digitalmars' C runtime, so
stuff like fopen is provided by _it_ and not Microsoft, which could introduce
its own set of quirks (and also means that the w* functions aren't even
available for anything in the C runtime). And that situation is about to become
that much more complicated when we start supporting Microsoft's runtime for
64-bit.

If there's a bug, it's in the usage of fopen and friends, not in fopen itself
(unless you count Microsoft's choice of CP_ACP as a bug, but that's not in our
control in either case).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list