-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix for cwstring, cconvert, transcode when !is_windows() #17410
Conversation
typealias Cwchar_t Int32 | ||
typealias Clong Int64 | ||
typealias Culong UInt64 | ||
typealias Cwchar_t UInt32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed from aliases to normal names, so it is clearer what's the difference between Windows and the rest of systems.
Should |
@@ -23,7 +23,7 @@ if is_windows() | |||
else | |||
typealias Clong Int | |||
typealias Culong UInt | |||
typealias Cwchar_t Int32 | |||
typealias Cwchar_t UInt32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change? wchar_t
seems to be signed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that Cwchar_t is passed as argument to the function transcode
and it seems to accept on all the cases unsigned integers. So I changed the alias from Int32
to UInt32
. Also now it is coherent with the definition of the aliases for windows, few lines above.
On the definition of transcode{T::Union{UInt8, UInt16}(::Type{T}, src::T)=src
, line 143 and beyond.
I'm trying to build with appveyor but it is still running. I was able to build it locally with no error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency with windows is not the point for this definition. This is what the C type is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, changing this definition will be subtly breaking. Functions that need to use Cwchar_t
should just be fixed to handle both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not expertise on it, should I reverse it to Int32
? Aren't the used to represent characters and therefore negatives are not useful?
Maybe Int32
is faster than UInt32
even if UInt32
doesn't break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I reverse it to
Int32
Yes.
Aren't the used to represent characters and therefore negatives are not useful?
Blame whoever define them to be signed in C. Cchar
is also signed on linux afaik.
You all did the work instead me! Thank you. At least this fix let me use PyCall, and plot figures with PyPlot. Squashed all commits into one. |
Fix for cwstring, convert, transcode when !is_windows() Fix thanks for 32-bits unix Fix is reusing code now for transcode() Dst_et by T Updated transcode method
5f12bff
to
36dea52
Compare
The PyCall problem is already fixed in PyCall |
On MacOS and Linux gcc, however, it looks like |
I would defer to / prefer being consistent with what GCC does on Linux, and what Clang does on Mac (if different than GCC). |
af50469
to
36dea52
Compare
I think that to be consistent, I should have to work on the reverse I've updated the code adding the |
@i-apellaniz, I think you may be looking at an out-of-date version of Julia. |
Yes! It is added already. Let me testt it againts PyCall, and soon if everything is ok, i'll close this pull request. Thanks all! |
On line
78
the functioncconvert()
calls fortranscode(Cwchar_t, String(s).data)
but latter it is not method fortrancode(::Type{UInt32}, Array{UInt8, 1})
on non windows machines.I also chaged
Cwchar_t
from Int32 to UInt32, since I think it could be a typo.This allows to pass
using PyCall
definitelly. See issue, PyCall/#295.More tests, with PyCall to come.