This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Do not define variable in header files
- From: Tristan Gingold <gingold at adacore dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Wed, 15 Jun 2011 04:39:27 +0200
- Subject: [RFA] Do not define variable in header files
Hi,
defining variables in header files is a UNIX extension (common variable) on ANSI-C, which results in duplicate symbols
if -fno-common is used (I always use this option on one of my compiler).
This patch avoids this issue by declaring the variable as extern in the header and defining it in a file.
Might be considered as obvious ?
Ok for trunk ?
Tristan.
2011-06-14 Tristan Gingold <gingold@adacore.com>
* python/py-events.h (gdb_py_events): Make it extern.
* python/py-evtregistry.c (gdb_py_events): Declare.
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index 6d4dae5..bd54418 100644
--- a/gdb/python/py-events.h
+++ b/gdb/python/py-events.h
@@ -51,7 +51,7 @@ typedef struct
} events_object;
/* Python events singleton. */
-events_object gdb_py_events;
+extern events_object gdb_py_events;
extern eventregistry_object *create_eventregistry_object (void);
extern int evregpy_no_listeners_p (eventregistry_object *registry);
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index e1b4346..67d5715 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -21,6 +21,8 @@
#include "command.h"
#include "py-events.h"
+events_object gdb_py_events;
+
static PyTypeObject eventregistry_object_type;
/* Implementation of EventRegistry.connect () -> NULL.