Discussion:
[Bug gdb/21527] New: macro expand not correct after #undef and #define
mjfoley at gmail dot com
2017-05-26 19:36:23 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21527

Bug ID: 21527
Summary: macro expand not correct after #undef and #define
Product: gdb
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: mjfoley at gmail dot com
Target Milestone: ---

Macro expansion does not honor #undef and #define, it seems to only use the
first #define encountered for a given macro name

in dwarves.h
dwarf(Dopey)
dwarf(Doc)
dwarf(Sleepy)
dwarf(Bashful)
dwarf(Happy)
dwarf(Sneezy)
dwarf(Grumpy)

in forest.c
main() {

printf("Deep in the forest.\n");
#define dwarf(name) printf("There was a dwarf named %s.\n",#name);
#include <dwarves.h>
// as you debug next will take you across each line of dwarves.h and expand
properly
#undef dwarf

int namelength[10]={0};
#define dwarf(name) namelength[strlen(#Name)]++;
#include <dwarves.h>
// as you debug here, "macro expand dwarf(Sleepy)" shows the printf not the ++
#undef

for (nl=0;nl<(sizeof(namelength)/sizeof(namelength[0]);nl++)
if (namelength[nl])
printf("%d dwarf/dwarves have name(s) %d letters long\n",
namelength[nl],nl):
}
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-04-18 17:22:00 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21527

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
Component|gdb |macros
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-06-27 16:33:09 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21527

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
I think this is a dup.

*** This bug has been marked as a duplicate of bug 7660 ***
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...