1
int findme()
{

    int input[120];
    int make00;
}

I want to find make00 in the program and after finding i want to print the function name which contain this variable. How do I do that PS:I am noob in c.(linux)

  • @AntoJurković I need function name in which variable is declared -_- – Prathiphan Desant Mar 07 '15 at 05:50
  • 3
    This is a *really* complicated task. It depends entirely on your environment, and requires that debugging information be enabled in your build: Windows (PE + PDB), Linux (ELF + DWARF), embedded (screwed). – Jonathon Reinhart Mar 07 '15 at 06:28
  • 1
    Find in source code or in resulting binary? If first, use C parser (e.g. clang) to parse full code and find there whatever you need. If latter, it is not possible/unreliable unless full debugging symbols enabled. – keltar Mar 07 '15 at 06:45
  • 1
    Note that in general, the same variable name may appear in many functions and source files that are part of the same program. Why do you think you need to do this? Are you writing a debugger? – Jonathan Leffler Mar 07 '15 at 06:47
  • I am making makefile generator that should automatically make the makefile in linux @JonathanLeffler – Prathiphan Desant Mar 07 '15 at 07:52
  • 3
    What makefile have to do with variable names? – keltar Mar 07 '15 at 07:52

1 Answers1

0

Have you considered good old bison + flex? The C/C++ grammar could be very simplified for your needs... I think this is your best option here.

W.F.
  • 13,888
  • 2
  • 34
  • 81