This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]