[review] Fix up complaints.h for namespace use

Message ID gerrit.1572371871000.I2abdae3a5853d36a221882cc7ede6c763255eed5@gnutoolchain-gerrit.osci.io
State New, archived
Headers

Commit Message

Simon Marchi (Code Review) Oct. 29, 2019, 5:57 p.m. UTC
  Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/422
......................................................................

Fix up complaints.h for namespace use

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.

Change-Id: Id397d4f7b850a855253fdf6b49cd7be1cddbecf5

gdb/ChangeLog
2019-10-29  Tom Tromey  <tromey@adacore.com>

	* complaints.h (stop_whining): Declare at top-level.
	(complaint): Don't declare stop_whining.

Change-Id: I2abdae3a5853d36a221882cc7ede6c763255eed5
---
M gdb/ChangeLog
M gdb/complaints.h
2 files changed, 9 insertions(+), 2 deletions(-)
  

Comments

Simon Marchi (Code Review) Nov. 27, 2019, 12:16 a.m. UTC | #1
Luis Machado has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/422
......................................................................


Patch Set 1:

(1 comment)

Just a nit, otherwise LGTM

| --- gdb/complaints.h
| +++ gdb/complaints.h
| @@ -20,15 +20,19 @@ /* Definitions for complaint handling during symbol reading in GDB.
|  
|  #if !defined (COMPLAINTS_H)
|  #define COMPLAINTS_H
|  
|  /* Helper for complaint.  */
|  extern void complaint_internal (const char *fmt, ...)
|    ATTRIBUTE_PRINTF (1, 2);
|  
| +/* This controls whether complaints are emitted.  */
| +

PS1, Line 29:

Spurious newline for the variable's comment?

| +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
|     example.  */
|  #define complaint(FMT, ...)					\
|    do								\
|      {								\
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d706ebb..8484dc2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@ 
 2019-10-29  Tom Tromey  <tromey@adacore.com>
 
+	* complaints.h (stop_whining): Declare at top-level.
+	(complaint): Don't declare stop_whining.
+
+2019-10-29  Tom Tromey  <tromey@adacore.com>
+
 	* windows-nat.c (get_windows_debug_event): Remove parameters.
 	(windows_nat_target::wait): Update.
 
diff --git a/gdb/complaints.h b/gdb/complaints.h
index f97ca7b..954cb4c 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 @@ 
 #define complaint(FMT, ...)					\
   do								\
     {								\
-      extern int stop_whining;					\
-								\
       if (stop_whining > 0)					\
 	complaint_internal (FMT, ##__VA_ARGS__);		\
     }								\