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

Detect C functions that can be declared with static linkage #7127

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mptre
Copy link
Contributor

@mptre mptre commented Dec 23, 2024

Currently limited to C as I assume the anonymous namespace should be favored for C++.

@chrchr-github
Copy link
Collaborator

clang-tidy has misc-use-internal-linkage: https://clang.llvm.org/extra/clang-tidy/checks/misc/use-internal-linkage.html
Not sure if we should attempt to duplicate that functionality.

@mptre
Copy link
Contributor Author

mptre commented Dec 23, 2024 via email

@firewave
Copy link
Collaborator

There is also the compiler warning -Wmissing-prototypes.

@firewave
Copy link
Collaborator

There is also the reverse case to be detected - prototypes which do not have an implementation - see https://trac.cppcheck.net/ticket/10670.

@danmar
Copy link
Owner

danmar commented Jan 2, 2025

Although, clang-tidy is less effective as it cannot detect functions used in a single TU while it's prototype resides in a header file.

It makes sense to me I think we should have this. Please finish it. 👍

There is also the compiler warning -Wmissing-prototypes.

That does not warn when there is a prototype but the function is only used in 1 TU.

Currently limited to C as I assume the anonymous namespace should be favored for
C++.
@mptre
Copy link
Contributor Author

mptre commented Jan 3, 2025

The failing tests have been resolved by now. Anything else that needs to be addressed before this can be merged?

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 this pull request may close these issues.

4 participants