From b6cfc72d0424739a696f18e2c05d0054557c765f Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 13 Feb 2022 21:03:40 -0800 Subject: [PATCH 1/3] Use static declaration for undeclared variable This was flagged by `-Wmissing-variable-declarations`. We could also (1) declare it in the header (2) but it in an anonymous namespace. --- src/callback_registry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callback_registry.cpp b/src/callback_registry.cpp index d527fe5..ae2949b 100644 --- a/src/callback_registry.cpp +++ b/src/callback_registry.cpp @@ -6,7 +6,7 @@ #include "callback_registry.h" #include "debug.h" -std::atomic nextCallbackId(1); +static std::atomic nextCallbackId(1); // ============================================================================ // Invoke functions From cf83ef6af08337f479eb24381fe0bea8799dee3a Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 13 Feb 2022 21:10:35 -0800 Subject: [PATCH 2/3] more instances in later_posix.cpp --- src/later_posix.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/later_posix.cpp b/src/later_posix.cpp index ef082bd..bed20b5 100644 --- a/src/later_posix.cpp +++ b/src/later_posix.cpp @@ -26,11 +26,11 @@ int initialized = 0; // The handles to the read and write ends of a pipe. We use this pipe // to signal R's input handler callback mechanism that we want to be // called back. -int pipe_in = -1; -int pipe_out = -1; +static int pipe_in = -1; +static int pipe_out = -1; -int dummy_pipe_in = -1; -int dummy_pipe_out = -1; +static int dummy_pipe_in = -1; +static int dummy_pipe_out = -1; // Whether the file descriptor is ready for reading, i.e., whether // the input handler callback is scheduled to be called. We use this From 6a5be78abcc66dd5eaf4536c6cedfb5ad46b0ac8 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 6 Mar 2022 23:33:30 -0800 Subject: [PATCH 3/3] more static variables; NEWS --- NEWS.md | 2 +- src/callback_registry.cpp | 4 ++-- src/later_posix.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index eaa12e8..b615832 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # later (development version) - +* Set file-level variables as `static` to avoid triggering `-Wmissing-variable-declarations` (@michaelchirico) # later 1.3.0 diff --git a/src/callback_registry.cpp b/src/callback_registry.cpp index ae2949b..3ce1933 100644 --- a/src/callback_registry.cpp +++ b/src/callback_registry.cpp @@ -21,8 +21,8 @@ enum InvokeResult { }; // This is set by invoke_c(). I -InvokeResult last_invoke_result; -std::string last_invoke_message; +static InvokeResult last_invoke_result; +static std::string last_invoke_message; // A wrapper for calling R_CheckUserInterrupt via R_ToplevelExec. void checkInterruptFn(void*) { diff --git a/src/later_posix.cpp b/src/later_posix.cpp index bed20b5..be6a791 100644 --- a/src/later_posix.cpp +++ b/src/later_posix.cpp @@ -21,7 +21,7 @@ extern void* R_GlobalContext; extern void* R_TopLevelContext; // Whether we have initialized the input handler. -int initialized = 0; +static int initialized = 0; // The handles to the read and write ends of a pipe. We use this pipe // to signal R's input handler callback mechanism that we want to be @@ -35,7 +35,7 @@ static int dummy_pipe_out = -1; // Whether the file descriptor is ready for reading, i.e., whether // the input handler callback is scheduled to be called. We use this // to avoid unnecessarily writing to the pipe. -bool hot = false; +static bool hot = false; // This mutex protects reading/writing of `hot` and of reading from/writing to // the pipe. Mutex m(tct_mtx_plain);