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

Use static declaration for undeclared variable #163

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

Conversation

MichaelChirico
Copy link
Contributor

This was flagged by -Wmissing-variable-declarations. We could also (1) declare it in the header (2) but it in an anonymous namespace.

This was flagged by `-Wmissing-variable-declarations`. We could also (1) declare it in the header (2) but it in an anonymous namespace.
@wch
Copy link
Member

wch commented Feb 14, 2022

Thanks -- after reading some more about static, I think that pretty much all the top-level variables in these files should be static, since we don't want them to be accessible from any other files. (I think they can be accessed from other .cpp files if they contain, for example extern int pipe_in.)

One thing I don't understand, though: in later_posix.cpp, there are other non-static variables, like hot and initialized. Why don't those variables raise the same warning?

@MichaelChirico
Copy link
Contributor Author

I had the same question myself! it might have to do with how they're referenced later...

sadly I'm not an expert here -- I only know what was flagged by our build tools

@wch
Copy link
Member

wch commented Feb 14, 2022

Can you do the following:

  • Make the rest of the top-level variables in those files static
  • Add a NEWS item

@MichaelChirico
Copy link
Contributor Author

OK I added more static qualifiers and a NEWS item, LMK if there's anything else

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.

2 participants