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

Avoid compiler warning about unused function #40

Closed
javaprog opened this issue Jan 26, 2021 · 0 comments · Fixed by #42
Closed

Avoid compiler warning about unused function #40

javaprog opened this issue Jan 26, 2021 · 0 comments · Fixed by #42

Comments

@javaprog
Copy link
Contributor

PyModule_Create in compat.h is declared as static but not marked as inline. As a consequence, for complex Python C bindings consisting of multiple compilation units, the compiler will emit a warning about the function being unused (except for the compilation unit that actually uses it). Adding the keyword inline will discard the function in compilation units that don't use it.

javaprog added a commit to javaprog/py3c that referenced this issue Jan 26, 2021
By marking the static function "inline", the compiler will only generate code for it if it is actually used. Without the keyword, the compiler will emit a warning if it is not used. For trivial Python C bindings this is not an issue, but if the code consists of multiple compilation units then this currently results in a warning for each such compilation unit without module initialization function.
encukou added a commit that referenced this issue Jan 26, 2021
Fixes: #40 (for GCC)

Making the functions `inline` would be better here, but `inline` is
not available in C90.

Includes tests to avoid future regressions :)
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

Successfully merging a pull request may close this issue.

1 participant