Posted to tcl by schelte at Tue Oct 25 22:47:52 GMT 2022view raw

  1. I'm trying to use hidapi (https://github.com/libusb/hidapi) via cffi.
  2. Because wchar_t has a different size on linux and windows, I tried to use a type alias. But I get an error:
  3.  
  4. package require cffi
  5. if {$tcl_platform(platform) eq "windows"} {
  6. set dll hidapi.dll
  7. cffi::alias define wchar_t ushort
  8. } else {
  9. set dll libhidapi-hidraw.so
  10. cffi::alias define wchar_t uint
  11. }
  12. cffi::Wrapper create hidapi [file join $dir $dll]
  13. hidapi function hid_get_product_string {int zero} {
  14. dev pointer.hid_device
  15. wstr {wchar_t[nchars] retval}
  16. nchars {size_t {default 256}}
  17. }
  18.  
  19. Invalid value "wchar_t[nchars]". Invalid base type. Error defining function hid_get_product_string.
  20.