Need to extract name of C variable from C declaration.
I only want the name of the declared variable. Everything else is not important to me:
char x; //ANS:x
int y; //ANS:y
char z; //ANS:z
int (*f)(double); //ANS:y
union un u; //ANS:u
struct x y; //ANS:y
struct w w; //ANS:w
struct z z; //ANS:z
double c; //ANS:c
Can somebody give me some shell or C code or Perl which extracts the name of a C variable from an arbitrary input? The above are only examples.
What is the input? C source code file? or an binary executable file?
Shouldn't the answer to your fourth entry (the function pointer) be "f," not "y?"
If you're parsing source code, awk is an easy language to use to do the parsing.
But, if you want to get a little more sophisticated, look at yacc to generate a C program to parse it all out for you, or, if you're masochistic, look at the parser in the g++ source code tree.
|All times are GMT -5. The time now is 04:53 AM.|