* [PATCH] Allow elf header to be used when __BEGIN_DECLS and __END_DECLS aren't defined.
@ 2020-10-26 23:34 Érico Nogueira
2020-10-27 7:46 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Érico Nogueira @ 2020-10-26 23:34 UTC (permalink / raw)
To: libc-alpha; +Cc: elfutils-devel, Érico Rolim
From: Érico Rolim <ericonr@disroot.org>
The elf/elf.h header is shared, verbatim, by the elfutils project.
However, elfutils can be used on systems with libcs other than glibc,
making the presence of __BEGIN_DECLS and __END_DECLS in the file
something that downstream distros have to add patches for.
Per https://sourceware.org/pipermail/elfutils-devel/2020q4/002994.html ,
the elfutils project would prefer to keep maintenance to a minimum,
which can be achieved by making this single header more portable.
---
This is mostly an initial PoC, and an additional comment for why this
is needed could be added to the file.
I accidentally sent the wrong patch a while ago, sorry!
elf/elf.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/elf/elf.h b/elf/elf.h
index ff9f1dadd5..d6578e8d72 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -21,7 +21,10 @@
#include <features.h>
-__BEGIN_DECLS
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Standard ELF types. */
@@ -4105,6 +4108,8 @@ enum
#define R_ARC_TLS_LE_S9 0x4a
#define R_ARC_TLS_LE_32 0x4b
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* elf.h */
--
2.29.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Allow elf header to be used when __BEGIN_DECLS and __END_DECLS aren't defined.
2020-10-26 23:34 [PATCH] Allow elf header to be used when __BEGIN_DECLS and __END_DECLS aren't defined Érico Nogueira
@ 2020-10-27 7:46 ` Florian Weimer
2020-10-27 14:18 ` Érico Nogueira
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2020-10-27 7:46 UTC (permalink / raw)
To: Érico Nogueira via Libc-alpha; +Cc: Érico Nogueira, elfutils-devel
* Érico Nogueira via Libc-alpha:
> This is mostly an initial PoC, and an additional comment for why this
> is needed could be added to the file.
>
> I accidentally sent the wrong patch a while ago, sorry!
extern "C++" does not have any effect for this header because it does
not declare anything that has language linkage.
I think you need to remove <features.h> to make the file self-contained.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Allow elf header to be used when __BEGIN_DECLS and __END_DECLS aren't defined.
2020-10-27 7:46 ` Florian Weimer
@ 2020-10-27 14:18 ` Érico Nogueira
0 siblings, 0 replies; 3+ messages in thread
From: Érico Nogueira @ 2020-10-27 14:18 UTC (permalink / raw)
To: Florian Weimer, Érico Nogueira via Libc-alpha; +Cc: Érico Nogueira
On Tue Oct 27, 2020 at 5:46 AM -03, Florian Weimer wrote:
> * Érico Nogueira via Libc-alpha:
>
> > This is mostly an initial PoC, and an additional comment for why this
> > is needed could be added to the file.
> >
> > I accidentally sent the wrong patch a while ago, sorry!
>
> extern "C++" does not have any effect for this header because it does
> not declare anything that has language linkage.
>
> I think you need to remove <features.h> to make the file self-contained.
>
> Thanks,
> Florian
> --
> Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
> Commercial register: Amtsgericht Muenchen, HRB 153243,
> Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael
> O'Neill
I've sent a v2 that removes <features.h> and the DECL macros, then.
Thanks for the input,
Érico
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-27 14:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 23:34 [PATCH] Allow elf header to be used when __BEGIN_DECLS and __END_DECLS aren't defined Érico Nogueira
2020-10-27 7:46 ` Florian Weimer
2020-10-27 14:18 ` Érico Nogueira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).