mjfoley at gmail dot com
2017-05-26 19:36:23 UTC
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):
}
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.
You are receiving this mail because:
You are on the CC list for the bug.