Fix up complaints.h for namespace use
authorTom Tromey <tromey@adacore.com>
Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 8 Apr 2020 20:47:58 +0000 (14:47 -0600)
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-04-08  Tom Tromey  <tromey@adacore.com>

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

gdb/ChangeLog
gdb/complaints.h

index aeab1ffa85631cd77bd7d0a2027c7e400a9a6485..0c288344af6de68afbc974502a10c4ebee468931 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-08  Tom Tromey  <tromey@adacore.com>
+
+       * complaints.h (stop_whining): Declare at top-level.
+       (complaint): Don't declare stop_whining.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
        * windows-nat.c (windows_nat::handle_output_debug_string):
index b3bb4068e1b65b710b9da8231aee0563e53f327d..6ad056d257efa79d3040db600c158debcecdd7ef 100644 (file)
 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__);                \
     }                                                          \