r-lib / later

Schedule an R function or formula to run after a specified period of time.
https://r-lib.github.io/later
Other
137 stars 27 forks source link

Use static declaration for undeclared variable #163

Open MichaelChirico opened 2 years ago

MichaelChirico commented 2 years ago

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

wch commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Can you do the following:

MichaelChirico commented 2 years ago

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