[v3,18/29] Fix up complaints.h for namespace use

Message ID 20200313190855.28662-19-tromey@adacore.com
State New
Headers show
Series
  • Windows code sharing + bug fix
Related show

Commit Message

Tom Tromey March 13, 2020, 7:08 p.m.
If 'complaint' is used in a namespace context, it will fail because
'stop_whining' is only declared at the top level.  This patch fixes
this problem in a simple way, by moving the declaration of
'stop_whining' out of the macro and to the top-level.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tromey@adacore.com>

	* complaints.h (stop_whining): Declare at top-level.
	(complaint): Don't declare stop_whining.
---
 gdb/ChangeLog    | 5 +++++
 gdb/complaints.h | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

-- 
2.21.1

Patch

diff --git a/gdb/complaints.h b/gdb/complaints.h
index b3bb4068e1b..6ad056d257e 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -25,6 +25,10 @@ 
 extern void complaint_internal (const char *fmt, ...)
   ATTRIBUTE_PRINTF (1, 2);
 
+/* This controls whether complaints are emitted.  */
+
+extern int stop_whining;
+
 /* Register a complaint.  This is a macro around complaint_internal to
    avoid computing complaint's arguments when complaints are disabled.
    Running FMT via gettext [i.e., _(FMT)] can be quite expensive, for
@@ -32,8 +36,6 @@  extern void complaint_internal (const char *fmt, ...)
 #define complaint(FMT, ...)					\
   do								\
     {								\
-      extern int stop_whining;					\
-								\
       if (stop_whining > 0)					\
 	complaint_internal (FMT, ##__VA_ARGS__);		\
     }								\