hidapi.h: fix API prototype for gcc flag -Wstrict-prototypes #207

Merged
borneoa merged 1 commit from fix-prototype into master 2020-11-23 13:04:19 -06:00
borneoa commented 2020-11-12 04:34:45 -06:00 (Migrated from github.com)

With gcc 10.2.0 and compile flag '-Wstrict-prototypes' the new
APIs in hidapi.h trigger a compile warning:

../hidapi/hidapi.h:481:32: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
481 | HID_API_EXPORT const struct hid_api_version* HID_API_CALL hid_version();
| ^~~~~~~~~~~~~~~
../hidapi/hidapi.h:491:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
491 | HID_API_EXPORT const char* HID_API_CALL hid_version_str();
| ^~~~~~~~~~~~~~

To replicate:
./bootstrap
CFLAG=-Wstrict-prototypes ./configure
make

This is an issue for other projects, like OpenOCD, that use hidapi
and compile by default with '-Wstrict-prototypes -Werror'; the
warning above causes compile error while including hidapi.h.

Fix the prototypes by adding 'void' in the empty parameter list.

Signed-off-by: Antonio Borneo borneo.antonio@gmail.com

With gcc 10.2.0 and compile flag '-Wstrict-prototypes' the new APIs in hidapi.h trigger a compile warning: ../hidapi/hidapi.h:481:32: warning: function declaration isn’t a prototype [-Wstrict-prototypes] 481 | HID_API_EXPORT const struct hid_api_version* HID_API_CALL hid_version(); | ^~~~~~~~~~~~~~~ ../hidapi/hidapi.h:491:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes] 491 | HID_API_EXPORT const char* HID_API_CALL hid_version_str(); | ^~~~~~~~~~~~~~ To replicate: ./bootstrap CFLAG=-Wstrict-prototypes ./configure make This is an issue for other projects, like OpenOCD, that use hidapi and compile by default with '-Wstrict-prototypes -Werror'; the warning above causes compile error while including hidapi.h. Fix the prototypes by adding 'void' in the empty parameter list. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Youw (Migrated from github.com) approved these changes 2020-11-12 05:19:00 -06:00
z3ntu commented 2020-11-12 05:37:15 -06:00 (Migrated from github.com)

Can we enable all these warning flags in CI as well that we're fixing so we don't regress?

Can we enable all these warning flags in CI as well that we're fixing so we don't regress?
borneoa commented 2020-11-12 08:23:36 -06:00 (Migrated from github.com)

Yes, it could be good to add more strict check during CI.
With OpenOCD we use
-Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror
not sure if this set covers all needs of hidapi, but tested after this patch does not show any further warning.

Yes, it could be good to add more strict check during CI. With OpenOCD we use -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror not sure if this set covers all needs of hidapi, but tested after this patch does not show any further warning.
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!207
No description provided.