We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
typedefs.rb: typedef :ushort, :wchar_t
typedef :ushort, :wchar_t
Is there a reason to hardcode wchar_t size?
Here's a trivial C program that on my system produces: wchar_t: 4, wint_t: 4:
wchar_t: 4, wint_t: 4
#include <stdio.h> #include <wchar.h> int main() { printf("wchar_t: %d, wint_t: %d\n", sizeof(wchar_t), sizeof(wint_t)); }
Related to this is the following issue (widechars.rb):
buffer_size = (txt.size + 1) * wchar_t.size buffer = FFI::Buffer.new(wchar_t, buffer_size)
The second argument to Buffer.new is the number of elements in the buffer (http://rubydoc.info/github/ffi/ffi/master/FFI/Buffer#initialize-instance_method), not the size of the buffer in bytes, so buffer_size is twice what's needed and that's why this code works on my machine, ironically.
I am no expert in FFI and C and all this, but I'm sure there must be a way to determine the size of wchar_t and alias is appropriately.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
typedefs.rb:
typedef :ushort, :wchar_t
Is there a reason to hardcode wchar_t size?
Here's a trivial C program that on my system produces:
wchar_t: 4, wint_t: 4
:Related to this is the following issue (widechars.rb):
The second argument to Buffer.new is the number of elements in the buffer (http://rubydoc.info/github/ffi/ffi/master/FFI/Buffer#initialize-instance_method), not the size of the buffer in bytes, so buffer_size is twice what's needed and that's why this code works on my machine, ironically.
I am no expert in FFI and C and all this, but I'm sure there must be a way to determine the size of wchar_t and alias is appropriately.
The text was updated successfully, but these errors were encountered: