This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Identify struct members present after directives
- From: Shakthi Kannan <shakthimaan at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 15 Mar 2012 14:49:27 +0530
- Subject: Identify struct members present after directives
Hi,
Suppose there exists a struct foo such that:
=== test.c ===
struct foo {
int a;
int b;
#ifndef BAR
int c;
#endif
int d;
};
int
main (void)
{
struct foo x;
return 0;
}
=== END ===
I want to be able to find using a tool/parser if there exists a struct
member after the #ifndef BAR ... #endif directive.
If I use:
$ gcc -g -c test.c
$ readelf -w test.o
I am able to identify DW_TAG_members for a, b, and c. And when I use:
$ gcc -DBAR -g -c test.c
$ readelf -w test.o
I get the DW_TAG_member details only for a and c, and can tell the
difference. Is there any other way by which this can be checked?
Appreciate any inputs in this regard.
Thanks!
SK
--
Shakthi Kannan
http://www.shakthimaan.com