You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there anyway this could work? The function needs an address to a location to store a C-string.
Here's the C++ function:
GOIO_DLL_INTERFACE_DECL gtype_int32 GoIO_GetNthAvailableDeviceName(
char *pBuf, // [out] ptr to buffer to store device name string.
gtype_int32 bufSize, // [in] number of bytes in buffer pointed to by pBuf.
// Strlen(pBuf) < bufSize, because the string is NULL terminated.
gtype_int32 vendorId, // [in] USB vendor id
gtype_int32 productId, //[in] USB product id
gtype_int32 N); //[in] index into list of known devices, 0 => first device in list.
Looking more closely at ffi-swig it's type_spec.rb does expect:
char *string;
to be turned into a :string.
I'm not much of a C programmer but is that correct? It seems in this case it should be a pointer.
Types like these are correctly turned into :string
const char *string;
The choice about turning a pointer into a string appears to be made in ffi-swig at lib/generator/type.rb:74:
def pointer
if @declaration.is_pointer? or @is_pointer > 0
@is_pointer += 1
if @full_decl.scan(/^p\.(.+)/).flatten[0]
ffi_type_from(@full_decl.scan(/^p\.(.+)/).flatten[0])
elsif @full_decl == 'char' and @is_pointer == 2
':string'
else
':pointer'
end
end
end
The text was updated successfully, but these errors were encountered:
See: http://groups.google.com/group/ruby-ffi/browse_thread/thread/98eaf51ab0386347
I have a C++ function that takes a pointer to a buffer where the function stores a C-string.
This is what I wrote and got working.
However if I use ffi-swig it generates a :string as the first parameter.
Is there anyway this could work? The function needs an address to a location to store a C-string.
Here's the C++ function:
Looking more closely at ffi-swig it's type_spec.rb does expect:
to be turned into a :string.
I'm not much of a C programmer but is that correct? It seems in this case it should be a pointer.
Types like these are correctly turned into :string
The choice about turning a pointer into a string appears to be made in ffi-swig at lib/generator/type.rb:74:
The text was updated successfully, but these errors were encountered: