Project

General

Profile

Bug #4555

macro side-effects with /usr/include/libelf.h

Added by Richard PALO almost 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2014-02-01
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

libelf.h contains the following snippet:

#undef _
#ifdef __STDC__
typedef void        Elf_Void;
#define _(a)        a
#else
typedef char        Elf_Void;
#define _(a)        ()
#undef const
#define const
#endif

(at the end, '_' is #undef'd)

This causes interference with other programs defining the macro '_', for example for NLS purposes. 'const' is may also be redefined...

A possible solution is to use #pragma push_macro/pop_macro but that would seemingly restrict builds to gcc>=4.4 and recent clang.

BTW, a current workaround is to put #pragma push_macro("_") and pop_macro("_")
around #include <gelf.h> or #include <libelf.h> statements.

Other ELF distros defining libelf.h don't have this problem.


Files

History

#1

Updated by Richard PALO almost 6 years ago

#2

Updated by Richard PALO almost 6 years ago

After reviewing the manner other illumos components avoided the above side-effects,
the attached patch seems appropriate.

#3

Updated by Andrew Stormont over 5 years ago

Patch looks good to me. Feel free to count me as a reviewer.

#4

Updated by Igor Pashev over 5 years ago

Why not just remove support for pre-ANSI C with those macros ?

#5

Updated by Richard PALO over 5 years ago

As the prevalent opinion was to drop the non STDC stuff, attached is a reworked patch.

I've so far done a successful incremental, and am proceeding to pull and rebase illumos-gate for a full build.

#6

Updated by Richard PALO over 5 years ago

no time like the present to relook, making libelf.h cstyle clean.
Another go...

#8

Updated by Dan McDonald over 5 years ago

  • Status changed from New to Resolved

See update from the git robot.

#9

Updated by Electric Monk over 5 years ago

git commit 7a3fc0ccaf807a654980fdce2d9187503628b99d

Author: Richard PALO <richard@NetBSD.org>

4555 macro side-effects with /usr/include/libelf.h
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Andy Stormont <AStormont@racktopsystems.com>
Reviewed by: Igor Pashev <pashev.igor@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>

#10

Updated by Yuri Pankov over 5 years ago

  • Category set to lib - userland libraries
  • Assignee set to Richard PALO
  • % Done changed from 0 to 100
  • Tags deleted (needs-triage)

Also available in: Atom PDF