Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Char-type is incorrectly sized #2907

Closed
vtjnash opened this issue Apr 22, 2013 · 4 comments
Closed

Char-type is incorrectly sized #2907

vtjnash opened this issue Apr 22, 2013 · 4 comments
Labels
domain:docs This change adds or pertains to documentation status:won't change Indicates that work won't continue on an issue or pull request system:windows Affects only Windows
Milestone

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 22, 2013

on windows, wint_t and wchar_t are declared unsigned short (Uint16)
http:https://msdn.microsoft.com/en-us/library/windows/desktop/aa367308(v=vs.85).aspx
and from _mingw.h:

typedef unsigned short wint_t;
typedef unsigned short wctype_t;

(somewhat amusingly, someone at microsoft apparently believes unsigned numbers can hold the value -1, as demonstrated by their documentation for this type. while not strictly wrong -- it can indeed hold the value 0xFFFF -- ok, yes it is wrong)

@mlubin
Copy link
Member

mlubin commented Apr 22, 2013

Not key to the discussion, but I think -1 is a valid and idiomatic way in C/C++ to refer to the largest value an unsigned type can hold.

@JeffBezanson
Copy link
Sponsor Member

This is relevant if you want to add a Cwctype_t type, but otherwise not. One could point out that Char is not the same size as C's char as well. Julia makes its own decision about what Char means, which is that it represents a unicode code point. Which cannot fit in 16 bits, so windows loses there I'm afraid. Char should not be used as a ccall argument type (should be fixed in #2901).

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Apr 22, 2013

@vtjnash vtjnash reopened this Apr 22, 2013
@JeffBezanson
Copy link
Sponsor Member

Also, while there's nothing we can do about it, using unsigned short for wint_t is certainly wrong, since the whole point of wint_t is to be able to represent a -1 that is not a valid code points. All unsigned short values are valid code points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation status:won't change Indicates that work won't continue on an issue or pull request system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

3 participants