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

Wrong declaration of a static function #2

Open
FStefanni opened this issue Dec 3, 2021 · 1 comment
Open

Wrong declaration of a static function #2

FStefanni opened this issue Dec 3, 2021 · 1 comment

Comments

@FStefanni
Copy link

  • Arduino board: esp32 dev
  • Arduino IDE version: no arduino-ide. arduino-cli version 0.20.1
  • List the steps to reproduce the problem below:

To reproduce the issue, just compile a sketch which uses this library. Maybe it is required to add -Wall -Wextra, the specific compiler flag seems to be -Wunused-function.

Just opened this issue to let you know about the following compiler warning message:

~/Arduino/libraries/Adafruit_SHTC3/Adafruit_SHTC3.h:51:16: warning: 'uint8_t crc8(const uint8_t*, int)' declared 'static' but never defined [-Wunused-function]
 static uint8_t crc8(const uint8_t *data, int len);

Actually, GCC is quite permissive in this case, since we are declaring a crc8() method inside each translation unit, with internal linkage, but then we do not provide its implementation (so this is not what is expected).
There are two possible fixes:

  1. If the crc8() method is "private" to the lib, just remove its declaration from the header.
  2. If it is intended to be publicly accessible, then remove static from both the header and the implementation.

Regards.

@caternuson
Copy link

I think option 1. Move the declaration to the source file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants