Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	       Binutils Development <binutils@sourceware.org>
Subject: [PATCH v2] Wrap BFD headers in extern "C"
Date: Tue, 10 Feb 2015 12:05:00 -0000	[thread overview]
Message-ID: <54D9F3EF.5070204@redhat.com> (raw)
In-Reply-To: <CA+=Sn1mDb7kr5urZOZ7v+-89VAMs39cHDHzL_0UuqXqXOU__jQ@mail.gmail.com>

On 02/09/2015 11:33 PM, Andrew Pinski wrote:

>> --- a/bfd/elf-bfd.h
>> +++ b/bfd/elf-bfd.h
>> @@ -22,6 +22,10 @@
>>  #ifndef _LIBELF_H_
>>  #define _LIBELF_H_ 1
>>
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>>  #include "elf/common.h"
>>  #include "elf/external.h"
>>  #include "elf/internal.h"
> 
> This is bad form to wrap header files also.

Thanks.  I admit I was a bit lazy here.

Here's a better patch.  The posted version of the GDB
series didn't link with --enable-targets=all yet (more extern "C"
issues), but with this one, along with a similar opcodes patch,
it will.

OK to apply?

---------------
From: Pedro Alves <palves@redhat.com>
Subject: [PATCH] Wrap BFD headers in extern "C"

These were the BFD changes needed for building a C++ GDB with
--enable-targets=all, on x86_64 Fedora 20.

For libbfd.h and libcoff.h, this does same as already done when
generating bfd.h: open extern "C" in the -in.h header, and close it
from the Makefile.

bfd/doc/ChangeLog:
2015-02-10  Pedro Alves  <palves@redhat.com>

	* Makefile.am (libbfd.h, libcoff.h): Close extern "C" scope.
	* Makefile.in: Regenerate.

bfd/ChangeLog:
2015-02-10  Pedro Alves  <palves@redhat.com>

	* libbfd-in.h [__cplusplus]: Open extern "C" scope.
	* libcoff-in.h [__cplusplus]: Open extern "C" scope.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.

	* elf-bfd.h [__cplusplus]: Wrap in extern "C".
	* mach-o.h [__cplusplus]: Wrap in extern "C".
	* som.h [__cplusplus]: Wrap in extern "C".
---
 bfd/doc/Makefile.am | 6 ++++++
 bfd/doc/Makefile.in | 6 ++++++
 bfd/elf-bfd.h       | 7 +++++++
 bfd/libbfd-in.h     | 4 ++++
 bfd/libbfd.h        | 7 +++++++
 bfd/libcoff-in.h    | 4 ++++
 bfd/libcoff.h       | 7 +++++++
 bfd/mach-o.h        | 8 ++++++++
 bfd/som.h           | 7 +++++++
 9 files changed, 56 insertions(+)

diff --git a/bfd/doc/Makefile.am b/bfd/doc/Makefile.am
index 779f361..52da14e 100644
--- a/bfd/doc/Makefile.am
+++ b/bfd/doc/Makefile.am
@@ -275,6 +275,9 @@ libbfd.h: $(LIBBFD_H_DEP)
 		./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
 	  esac; \
 	done
+	echo "#ifdef __cplusplus" >> $@
+	echo "}" >> $@
+	echo "#endif" >> $@
 
 LIBCOFF_H_DEP = \
 	$(srcdir)/../libcoff-in.h	\
@@ -294,6 +297,9 @@ libcoff.h: $(LIBCOFF_H_DEP)
 		./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
 	  esac; \
 	done
+	echo "#ifdef __cplusplus" >> $@
+	echo "}" >> $@
+	echo "#endif" >> $@
 
 BFD_H_DEP = \
 	$(srcdir)/../bfd-in.h 		\
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index 78d8ec0..72099f1 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -960,6 +960,9 @@ libbfd.h: $(LIBBFD_H_DEP)
 		./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
 	  esac; \
 	done
+	echo "#ifdef __cplusplus" >> $@
+	echo "}" >> $@
+	echo "#endif" >> $@
 
 libcoff.h: $(LIBCOFF_H_DEP)
 	echo "$(LIBCOFF_H_DEP)" | sed -f $(srcdir)/header.sed > $@
@@ -972,6 +975,9 @@ libcoff.h: $(LIBCOFF_H_DEP)
 		./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
 	  esac; \
 	done
+	echo "#ifdef __cplusplus" >> $@
+	echo "}" >> $@
+	echo "#endif" >> $@
 
 bfd.h: $(BFD_H_DEP)
 	echo "$(BFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 49ffe79..495053d 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -27,6 +27,10 @@
 #include "elf/internal.h"
 #include "bfdlink.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* The number of entries in a section is its size divided by the size
    of a single entry.  This is normally only applicable to reloc and
    symbol table sections.
@@ -2540,4 +2544,7 @@ extern asection _bfd_elf_large_com_section;
     (!(H)->unique_global \
      && ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic)))
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* _LIBELF_H_ */
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index cb7805f..7c661e3 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -24,6 +24,10 @@
 
 #include "hashtab.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Align an address upward to a boundary, expressed as a number of bytes.
    E.g. align to an 8-byte boundary with argument of 8.  Take care never
    to wrap around if the address is within boundary-1 of the end of the
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index a1c0a01..bd56afb 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -29,6 +29,10 @@
 
 #include "hashtab.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Align an address upward to a boundary, expressed as a number of bytes.
    E.g. align to an 8-byte boundary with argument of 8.  Take care never
    to wrap around if the address is within boundary-1 of the end of the
@@ -3015,3 +3019,6 @@ void *bfd_arch_default_fill (bfd_size_type count,
     bfd_boolean code);
 
 /* Extracted from elf.c.  */
+#ifdef __cplusplus
+}
+#endif
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index 6d00db0..34e71a8 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -22,6 +22,10 @@
 #include "bfdlink.h"
 #include "coff-bfd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Object file tdata; access macros.  */
 
 #define coff_data(bfd)		      ((bfd)->tdata.coff_obj_data)
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index df0e00f..ee72de3 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -26,6 +26,10 @@
 #include "bfdlink.h"
 #include "coff-bfd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Object file tdata; access macros.  */
 
 #define coff_data(bfd)		      ((bfd)->tdata.coff_obj_data)
@@ -951,3 +955,6 @@ typedef struct
    PE object file.  */
 #define bfd_pei_p(abfd) \
   (CONST_STRNEQ ((abfd)->xvec->name, "pei-"))
+#ifdef __cplusplus
+}
+#endif
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index bc694ba..0445398 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -24,6 +24,10 @@
 #include "bfd.h"
 #include "mach-o/loader.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct bfd_mach_o_header
 {
   unsigned long magic;
@@ -746,4 +750,8 @@ bfd_mach_o_backend_data;
 #define SYM_MACHO_FIELDS_UNSET ((bfd_vma) -1)
 #define SYM_MACHO_FIELDS_NOT_VALIDATED ((bfd_vma) -2)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _BFD_MACH_O_H_ */
diff --git a/bfd/som.h b/bfd/som.h
index a300104..7f8a5ba 100644
--- a/bfd/som.h
+++ b/bfd/som.h
@@ -40,6 +40,10 @@
 #include <dl.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
 /* BSD uses a completely different scheme for object file identification.
    so for now, define _PA_RISC_ID to accept any random value for a model
@@ -235,4 +239,7 @@ int **       hppa_som_gen_reloc_type           (bfd *, int, int, enum hppa_reloc
 bfd_boolean  bfd_som_attach_compilation_unit   (bfd *, const char *, const char *, const char *, const char *);
 asection *   bfd_section_from_som_symbol       (bfd *abfd, struct som_external_symbol_dictionary_record *symbol);
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* _SOM_H */
-- 
1.9.3



  reply	other threads:[~2015-02-10 12:05 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09 23:20 [PATCH 00/36] Support building GDB as a C++ program Pedro Alves
2015-02-09 23:20 ` [PATCH 02/36] Add --enable-build-with-cxx configure switch Pedro Alves
2015-02-10 22:11   ` Yao Qi
2015-02-27 13:24     ` Pedro Alves
2015-02-27 14:20       ` Yao Qi
2015-02-27 16:29         ` Pedro Alves
2015-02-09 23:21 ` [PATCH 03/36] C++ keyword cleanliness, mostly auto-generated Pedro Alves
2015-02-11  7:57   ` Joel Brobecker
2015-02-11  8:52     ` Phil Muldoon
2015-02-11 10:27     ` Pedro Alves
2015-02-11 10:51       ` Pedro Alves
2015-02-12 12:19         ` Joel Brobecker
2015-02-12 13:14           ` Pedro Alves
2015-02-12 14:43             ` Pedro Alves
2015-02-12 14:59               ` Joel Brobecker
2015-02-27 17:41         ` Pedro Alves
2015-02-09 23:21 ` [PATCH 19/36] Exported const objects Pedro Alves
2015-02-09 23:21 ` [PATCH 16/36] x86 Linux/ptrace: fix offsetof usage in C++ mode Pedro Alves
2015-02-09 23:21 ` [PATCH 25/36] python/python-internal.h: enum ‘ext_lang_rc’ not defined Pedro Alves
2015-02-09 23:21 ` [PATCH 28/36] Move exception_none to common code, and use it Pedro Alves
2015-02-09 23:21 ` [PATCH 17/36] mi/mi-cmd-stack.c|frame filters: print_values <-> ext_lang_frame_args Pedro Alves
2015-02-09 23:21 ` [PATCH 29/36] Normalize TRY_CATCH exception handling block Pedro Alves
2015-02-09 23:21 ` [PATCH 27/36] catch_command_errors: Remove 'mask' parameter Pedro Alves
2015-02-09 23:21 ` [PATCH 04/36] Fix struct, union, and enum nesting in C++ Pedro Alves
2015-02-09 23:21 ` [PATCH 26/36] Adjust self tests to cope with GDB built as a C++ program Pedro Alves
2015-02-09 23:21 ` [PATCH 11/36] Make functions and variables exported by the IPA be extern "C" Pedro Alves
2015-02-09 23:21 ` [PATCH 31/36] Split TRY_CATCH into TRY + CATCH Pedro Alves
2015-03-07 15:58   ` Pedro Alves
2015-02-09 23:21 ` [PATCH 12/36] proc-service, extern "C" Pedro Alves
2015-02-09 23:21 ` [PATCH 22/36] Remove duplicate const Pedro Alves
2015-02-09 23:21 ` [PATCH 23/36] gdbarch.h: include regcache.h Pedro Alves
2015-02-09 23:21 ` [PATCH 15/36] Don't forward declare enum target_hw_bp_type Pedro Alves
2015-02-09 23:21 ` [PATCH 13/36] target.h: Include infrun.h Pedro Alves
2015-02-09 23:21 ` [PATCH 21/36] opcodes/microblaze: Rename 'or', 'and', 'xor' to avoid C++ conflict Pedro Alves
2015-02-10 15:05   ` Michael Eager
2015-02-10 18:11     ` Pedro Alves
2015-02-09 23:21 ` [PATCH 05/36] Fix redefinition errors in C++ mode Pedro Alves
2015-02-11 10:09   ` Yao Qi
2015-02-11 11:30     ` Pedro Alves
2015-02-11 11:39       ` [PATCH] xcoffread.c: delete 'within_function' definition (Re: [PATCH 05/36] Fix redefinition errors in C++ mode) Pedro Alves
2015-02-09 23:21 ` [PATCH 09/36] floatformat.h: Wrap in extern "C" Pedro Alves
2015-02-09 23:35   ` Andrew Pinski
2015-02-09 23:49     ` Pedro Alves
2015-02-12 11:49       ` Pedro Alves
2015-02-18 19:55         ` Jakub Jelinek
2015-02-14 17:29       ` Doug Evans
2015-02-14 18:36         ` Pedro Alves
2015-02-14 22:46           ` Doug Evans
2015-02-09 23:21 ` [PATCH 20/36] gdbserver/tracepoint: Add cast sockaddr_un/sockaddr cast Pedro Alves
2015-02-09 23:21 ` [PATCH 08/36] elf-bfd.h: Wrap in extern "C" Pedro Alves
2015-02-09 23:33   ` Andrew Pinski
2015-02-10 12:05     ` Pedro Alves [this message]
2015-02-11  0:36       ` [PATCH v2] Wrap BFD headers " Alan Modra
2015-02-11 10:08         ` Pedro Alves
2015-02-09 23:22 ` [PATCH 36/36] Make TRY/CATCH use real C++ try/catch in C++ mode Pedro Alves
2015-02-09 23:22 ` [PATCH 32/36] TRY_CATCH -> TRY+CATCH+END_CATCH everywhere Pedro Alves
2015-02-09 23:22 ` [PATCH 33/36] TRY_CATCH -> TRY+CATCH+END_CATCH, the manual conversions Pedro Alves
2015-02-09 23:35 ` [PATCH 18/36] Rename struct lzma_stream to avoid clash with system header Pedro Alves
2015-02-09 23:45 ` [PATCH 06/36] record-btrace.c: Remove redefinitions Pedro Alves
2015-02-09 23:46 ` [PATCH 35/36] kill volatile struct gdb_exception Pedro Alves
2015-02-09 23:49 ` [PATCH 00/36] Support building GDB as a C++ program Doug Evans
2015-02-09 23:50 ` [PATCH 34/36] more making TRY/CATCH callers look more like real C++ try/catch blocks Pedro Alves
2015-03-07 15:59   ` Pedro Alves
2015-02-09 23:51 ` [PATCH 14/36] Do not do arithmetic on enum types Pedro Alves
2015-02-09 23:51 ` [PATCH 07/36] Make array object extern Pedro Alves
2015-02-27 22:47   ` Simon Marchi
2015-02-27 22:58     ` Pedro Alves
2015-02-27 23:04       ` Simon Marchi
2015-02-09 23:53 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
2015-02-09 23:35   ` Pedro Alves
2015-02-27 16:23   ` Pedro Alves
2015-02-09 23:54 ` [PATCH 30/36] quit_force: Replace TRY_CATCH wrapper macros Pedro Alves
2015-02-09 23:54 ` [PATCH 10/36] Add extern "C" to declarations of C symbols Pedro Alves
2015-02-11 11:51   ` Pedro Alves
2015-02-10  0:21 ` [PATCH 24/36] breakpoint.h: move enum ‘print_stop_action’ Pedro Alves
2015-02-11 12:28   ` Yao Qi
2015-02-10 15:07 ` [PATCH 00/36] Support building GDB as a C++ program Michael Eager
2015-02-11 17:15 ` Yao Qi
2015-02-12 11:34   ` Pedro Alves
2015-02-17 23:19 ` Patrick Palka
2015-02-18 21:54   ` Yao Qi
2015-02-18 23:49     ` Patrick Palka
2015-02-27 18:19 ` Pedro Alves
2015-02-27 23:52   ` Patrick Palka
2015-02-28  0:09     ` Pedro Alves
2015-03-07 16:01   ` Pedro Alves
2015-03-07 17:58     ` [all pushed] " Pedro Alves
2015-03-16  4:42       ` asmwarrior
2015-03-16  5:05         ` asmwarrior
2015-03-16  5:22           ` asmwarrior
2015-03-16  7:15             ` asmwarrior
2015-03-16  8:20               ` asmwarrior
2015-03-16 11:43                 ` [pushed] stub-termcap.c: prototype tputs's parameter's parameter, for C++ mode (Re: [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program) Pedro Alves
2015-03-16 11:46                 ` [pushed] stub termcap, add extern "C" " Pedro Alves
2015-03-16 11:55                 ` [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program Pedro Alves
2015-03-16 11:42           ` Pedro Alves
2015-05-15  8:13             ` asmwarrior
2015-05-15  8:24               ` asmwarrior
2015-05-15 15:09                 ` Pedro Alves
2015-05-15 15:04               ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54D9F3EF.5070204@redhat.com \
    --to=palves@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pinskia@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox