This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] xcoffread.c: delete 'within_function' definition (Re: [PATCH 05/36] Fix redefinition errors in C++ mode)
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 11 Feb 2015 11:39:39 +0000
- Subject: [PATCH] xcoffread.c: delete 'within_function' definition (Re: [PATCH 05/36] Fix redefinition errors in C++ mode)
- Authentication-results: sourceware.org; auth=none
- References: <1423524046-20605-1-git-send-email-palves at redhat dot com> <1423524046-20605-6-git-send-email-palves at redhat dot com> <54DB2A32 dot 1030109 at gmail dot com> <54DB3D5C dot 3040106 at redhat dot com>
On 02/11/2015 11:30 AM, Pedro Alves wrote:
> On 02/11/2015 10:08 AM, Yao Qi wrote:
>> On 09/02/15 23:20, Pedro Alves wrote:
>>
>>> The intent of static here is naturally to avoid making these objects
>>> visible outside the compilation unit. The equivalent in C++ would be
>>> to instead define the objects in the anonymous namespace. But given
>>> that it's desirable to leave the codebase compiling as both C and C++
>>> for a while, this just makes the objects extern.
>>
>> It is a little pity to do so, but I don't know any other better way.
>> The patch looks good to me.
>
> Yeah, we can revisit when we require C++. We already tend to give
> fairly unique names to these objects, and, GDB will fail to link
> in C++ with multiple definition errors if there's a collision
> we miss.
Speaking of which, here's one that linking an --enable-targets=all
build in C++ mode found. In C (-fcommon), the linker merges both instances
of within_function, so it's really one variable.
Pushed as obvious.
------------
>From 18ad82c16379e7ed7daa3043abdacee1d934867d Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 10 Feb 2015 11:01:21 +0000
Subject: [PATCH] xcoffread.c: delete 'within_function' definition
Linking GDB as a C++ program, we get:
src/gdb/buildsym.c:226: multiple definition of `within_function'
xcoffread.o:src/gdb/xcoffread.c:181: first defined here
gdb/
2015-02-11 Pedro Alves <palves@redhat.com>
* xcoffread.c (within_function): Delete.
---
gdb/ChangeLog | 4 ++++
gdb/xcoffread.c | 5 -----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 17a00a0..02232a5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-11 Pedro Alves <palves@redhat.com>
+
+ * xcoffread.c (within_function): Delete.
+
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index dde9185..6015711 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -119,11 +119,6 @@ static CORE_ADDR first_object_file_end;
#define INITIAL_STABVECTOR_LENGTH 40
-/* Nonzero if within a function (so symbols should be local,
- if nothing says specifically). */
-
-int within_function;
-
/* Size of a COFF symbol. I think it is always 18, so I'm not sure
there is any reason not to just use a #define, but might as well
ask BFD for the size and store it here, I guess. */
--
1.9.3