Skip to content
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.h: fix API prototype for gcc flag -Wstrict-prototypes #207

Merged
merged 1 commit into from
Nov 23, 2020

Conversation

borneoa
Copy link
Contributor

@borneoa borneoa commented Nov 12, 2020

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>
@z3ntu
Copy link
Collaborator

z3ntu commented Nov 12, 2020

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

@borneoa
Copy link
Contributor Author

borneoa commented Nov 12, 2020

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.

@Youw Youw merged commit 8caf8c8 into libusb:master Nov 23, 2020
@mcuee mcuee added build system/CI Anything related to building the project or running on CI Core Related to common codes like hidapi.h labels Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system/CI Anything related to building the project or running on CI Core Related to common codes like hidapi.h
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants