later icon indicating copy to clipboard operation
later copied to clipboard

Use static declaration for undeclared variable

Open MichaelChirico opened this issue 3 years ago • 4 comments

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

MichaelChirico avatar Feb 14 '22 05:02 MichaelChirico

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?

wch avatar Feb 14 '22 15:02 wch

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

MichaelChirico avatar Feb 14 '22 17:02 MichaelChirico

Can you do the following:

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

wch avatar Feb 14 '22 19:02 wch

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

MichaelChirico avatar Mar 07 '22 07:03 MichaelChirico