Skip to content

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

Merged
Youw merged 1 commit into
libusb:masterfrom
borneoa:fix-prototype
Nov 23, 2020
Merged

hidapi.h: fix API prototype for gcc flag -Wstrict-prototypes#207
Youw merged 1 commit into
libusb:masterfrom
borneoa:fix-prototype

Conversation

@borneoa

@borneoa borneoa commented Nov 12, 2020

Copy link
Copy Markdown
Contributor

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

z3ntu commented Nov 12, 2020

Copy link
Copy Markdown
Collaborator

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

@borneoa

borneoa commented Nov 12, 2020

Copy link
Copy Markdown
Contributor Author

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