[Bug gdb/21527] New: macro expand not correct after #undef and #define

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/21527] New: macro expand not correct after #undef and #define

fweimer at redhat dot com
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.
Reply | Threaded
Open this post in threaded view
|

[Bug macros/21527] macro expand not correct after #undef and #define

fweimer at redhat dot com
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.
Reply | Threaded
Open this post in threaded view
|

[Bug macros/21527] macro expand not correct after #undef and #define

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
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.