-
Notifications
You must be signed in to change notification settings - Fork 396
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
hidapi 0.14.0 for Windows with C++-Builder 11 #630
Comments
I've never tried to compile HIDAPI with clang on Windows. |
Which code path is used in case of BorlandC ? Is BorlandC using clang? I think we should add clang-cl to our CI, than we should see such issues. Since is clang-cl.exe is command line compatible to the MSVC cl.exe, it should easy to set up. |
At first a correction: when copying the text, the underscores got lost due to wrong formatting. More correct: From C++ Builder 10 Seattle on you had the choice between the classical Borland compiler and a CLANG based compiler. |
I think we need to invert the condition here, as the Microsoft compiler seems to be the exception and not the other way around. Let's use |
@JoergAtGithub In hidapi_hidsdi.h: In hid.c , line 267: the compiler warns: If swprintf has a size (msg_len + 1) as the second parameter, isn't it the C++ function? |
Do you have a reference where you've got it from? |
I searched for this, and it seems that the original |
* Invert preprocessor condition, as the Microsoft compiler seems to be the special case - not the other way around * Removed redefinition of typedef 'PHIDP_PREPARSED_DATA' in hidapi_hidsdi.h to match the original hidsdi.h As reported in #630
Closed by automation. |
My PR #634 fixed only the first two problems. |
@Youw I found the different definition there: I once installed CodeLite and found both declaration: There was also a similar discussion a few years ago: |
This answer: https://stackoverflow.com/a/35072422/3697939 summarizes my oppinion on this. |
@Youw I can corfirm that the error/warning related to the 2 include files is solved with the new ones The confusion with swprintf and the 32-bit linker error |
The swprintf issue seems to be a compiler bug. #include <stdio.h> #if !defined(__cplusplus) && defined(BORLANDC) The other problems still exist. |
I have been using hid.c in a version from before September 2019 for
32- and 64-bit Windows programs.
Compiler is CLANG in C++ Builder 11.3 (and earlier) IDE.
hid.c was compiled and embedded into the main program, no dll.
The main program had in most cases a GUI.
It worked for me, except for rising an exception when closing the program, and
hence closing the HID device.
When compiling the current 0.14.0 several errors / warning occurred:
in hidapi_descriptor_reconstruct.h:
#if defined(MINGW32) || defined(CYGWIN)
...
#else
union {
hid_pp_cap caps[];
hid_pp_link_collection_node LinkCollectionArray[];
};
#endif
[bcc32c error] hidapi_descriptor_reconstruct.h(220): type name requires a specifier or qualifier
[bcc32c error] hidapi_descriptor_reconstruct.h(220): expected ';' at end of declaration list
When extending the first line to
#if defined(MINGW32) || defined(CYGWIN) || defined(clang)
it works. It also works with BORLANDC .
Compiler warning "[bcc64 Warnung] hidapi_hidsdi.h(43): redefinition of typedef 'PHIDP_PREPARSED_DATA' is a C11 feature"
typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;
was previously defined in hidapi_hidpi.h(39)
Won't be the typedef in hidapi_hidpi.h(39) sufficient?
Second warning from hid.c in line 267:
int printf_written = swprintf(msg, msg_len + 1, L"%.*ls: (0x%08X) %.*ls", (int)op_len, op, error_code, (int)system_err_len, system_err_buf);
[bcc64 Warnung] hid.c(267): incompatible integer to pointer conversion passing 'unsigned long' to parameter of type 'const wchar_t *' (aka 'const unsigned short *')
There is a linker error with the 32-bit compiler version:
[ilink32 Fehler] Fatal: Invalid VIRDEF Fixup-Index in Modul 'hid.c'
It works when creating a 64-bit version.
When running a program
shows a length of zero.
returns the correct value.
The following code was used for it:
struct hid_device_ {
HANDLE device_handle;
BOOL blocking;
USHORT output_report_length;
size_t input_report_length;
void *last_error_str;
DWORD last_error_num;
BOOL read_pending;
char *read_buf;
OVERLAPPED ol;
};
int HID_API_EXPORT_CALL HID_API_CALL hid_get_input_report_length(hid_device *dev)
{
return dev->input_report_length;
}
int HID_API_EXPORT_CALL HID_API_CALL hid_get_output_report_length(hid_device *dev)
{
return dev->output_report_length;
}
Sending data to a HID device seems to work.
The exception when closing the program still exists.
Any hints welcome!
The text was updated successfully, but these errors were encountered: