[v2,07/16] libdw: Fixes compile of dwarf_whatattr.c and dwarf_whatform.c

Message ID 20221217165213.152-8-luoyonggang@gmail.com
State Rejected
Headers
Series Patches for building with mingw/gcc msvc/clang-cl |

Commit Message

Yonggang Luo Dec. 17, 2022, 4:52 p.m. UTC
  If __OPTIMIZE__ is defined, then compile  dwarf_whatattr.c and dwarf_whatform.c
will cause symbol conflict between
dwarf_whatattr.c and libdw.h,
dwarf_whatform.c and libdw.h,

So always undefined __OPTIMIZE__ when compiling these two files

The error message is:
dwarf_whatform.c

[build] C:\work\xemu\elfutils\libdw\dwarf_whatform.c(39,1): error: redefinition of 'dwarf_whatform'
[build] dwarf_whatform (Dwarf_Attribute *attr)
[build] ^
[build] C:\work\xemu\elfutils\libdw/libdw.h(1110,1): note: previous definition is here
[build] dwarf_whatform (Dwarf_Attribute *attr)
[build] ^
[build] 1 error generated.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 libdw/dwarf_whatattr.c | 9 ++++-----
 libdw/dwarf_whatform.c | 9 ++++-----
 2 files changed, 8 insertions(+), 10 deletions(-)
  

Comments

Mark Wielaard Feb. 23, 2023, 12:25 p.m. UTC | #1
Hi,

On Sun, 2022-12-18 at 00:52 +0800, Yonggang Luo via Elfutils-devel
wrote:
> If __OPTIMIZE__ is defined, then compile  dwarf_whatattr.c and dwarf_whatform.c
> will cause symbol conflict between
> dwarf_whatattr.c and libdw.h,
> dwarf_whatform.c and libdw.h,
> 
> So always undefined __OPTIMIZE__ when compiling these two files
> 

I don't think this is correct. See also the discussion around v1 of
this patch:
https://inbox.sourceware.org/elfutils-devel/0bc05adaf492c5f57b0b45f520be14b78f3fbd53.camel@klomp.org/

Cheers,

Mark
  

Patch

diff --git a/libdw/dwarf_whatattr.c b/libdw/dwarf_whatattr.c
index d664b021..01d92307 100644
--- a/libdw/dwarf_whatattr.c
+++ b/libdw/dwarf_whatattr.c
@@ -30,13 +30,12 @@ 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
+#ifndef __OPTIMIZE__
+#define __OPTIMIZE__
+#endif
 #include <dwarf.h>
 #include "libdwP.h"
 
 
 unsigned int
-dwarf_whatattr (Dwarf_Attribute *attr)
-{
-  return attr == NULL ? 0 : attr->code;
-}
+dwarf_whatattr (Dwarf_Attribute *attr);
diff --git a/libdw/dwarf_whatform.c b/libdw/dwarf_whatform.c
index dee29a9f..9b3e41e6 100644
--- a/libdw/dwarf_whatform.c
+++ b/libdw/dwarf_whatform.c
@@ -30,13 +30,12 @@ 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
+#ifndef __OPTIMIZE__
+#define __OPTIMIZE__
+#endif
 #include <dwarf.h>
 #include "libdwP.h"
 
 
 unsigned int
-dwarf_whatform (Dwarf_Attribute *attr)
-{
-  return attr == NULL ? 0 : attr->form;
-}
+dwarf_whatform (Dwarf_Attribute *attr);
\ No newline at end of file