Project

General

Profile

Actions

Bug #4555

closed

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

Added by Richard PALO almost 10 years ago. Updated over 9 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:
Gerrit CR:
External Bug:

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

Actions #1

Updated by Richard PALO almost 10 years ago

Actions #2

Updated by Richard PALO almost 10 years ago

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

Actions #3

Updated by Andrew Stormont almost 10 years ago

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

Actions #4

Updated by Igor Pashev almost 10 years ago

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

Actions #5

Updated by Richard PALO over 9 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.

Actions #6

Updated by Richard PALO over 9 years ago

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

Actions #8

Updated by Dan McDonald over 9 years ago

  • Status changed from New to Resolved

See update from the git robot.

Actions #9

Updated by Electric Monk over 9 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>

Actions #10

Updated by Yuri Pankov over 9 years ago

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

Also available in: Atom PDF