Patchwork [08/36] elf-bfd.h: Wrap in extern "C".

login
register
mail settings
Submitter Pedro Alves
Date Feb. 9, 2015, 11:20 p.m.
Message ID <1423524046-20605-9-git-send-email-palves@redhat.com>
Download mbox | patch
Permalink /patch/4983/
State New
Headers show

Comments

Pedro Alves - Feb. 9, 2015, 11:20 p.m.
Just like bfd-in2.h.  So that C++ programs, such as when GDB is built
as a C++ program, can use it.

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

	* elf-bfd.h [__cplusplus]: Wrap in extern "C".
---
 bfd/elf-bfd.h | 7 +++++++
 1 file changed, 7 insertions(+)
pinskia@gmail.com - Feb. 9, 2015, 11:33 p.m.
On Mon, Feb 9, 2015 at 3:20 PM, Pedro Alves <palves@redhat.com> wrote:
> Just like bfd-in2.h.  So that C++ programs, such as when GDB is built
> as a C++ program, can use it.
>
> bfd/ChangeLog:
> 2015-02-09  Pedro Alves  <palves@redhat.com>
>
>         * elf-bfd.h [__cplusplus]: Wrap in extern "C".
> ---
>  bfd/elf-bfd.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
> index 49ffe79..0587cc2 100644
> --- 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,
Andrew

> @@ -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_ */
> --
> 1.9.3
>

Patch

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 49ffe79..0587cc2 100644
--- 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"
@@ -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_ */