Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: conflicting elf definitions in system headers
wiz> Are these headers expected to conflict, and the bug is in the program
wiz> including both? In this case, which header should it include?
The <gelf.h> and <libelf.h> headers should suffice in themselves - they don't
need OS-specific #includes.
Perhaps the sense of the check needs to be reversed?
--- pkg_elf.c-- 2025-02-10 11:20:10.073896326 +0000
+++ pkg_elf.c 2025-02-10 11:20:04.688882272 +0000
@@ -48,7 +48,7 @@
#include <fcntl.h>
#include <gelf.h>
#include <libgen.h>
-#if defined(HAVE_LINK_H) && !defined(__DragonFly__) && defined(HAVE_LIBELF_H)
+#if defined(HAVE_LINK_H) && !defined(__DragonFly__) && !defined(HAVE_LIBELF_H)
#include <link.h>
#endif
#include <paths.h>
In fact <gelf.h> brings in <libelf.h>, so the independent inclusion of
<libelf.h>
isn't needed either. So the following patch would be even better.
--- pkg_elf.c-- 2025-02-10 11:20:10.073896326 +0000
+++ pkg_elf.c 2025-02-10 11:37:08.706097879 +0000
@@ -48,16 +48,13 @@
#include <fcntl.h>
#include <gelf.h>
#include <libgen.h>
-#if defined(HAVE_LINK_H) && !defined(__DragonFly__) && defined(HAVE_LIBELF_H)
+#if defined(HAVE_LINK_H) && !defined(__DragonFly__) && !defined(HAVE_LIBELF_H)
#include <link.h>
#endif
#include <paths.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
-#ifdef HAVE_LIBELF
-#include <libelf.h>
-#endif
#include <bsd_compat.h>
Regards,
Joseph Koshy
Home |
Main Index |
Thread Index |
Old Index