Are you trying to write a compiler? This is not a simple problem. If this is a homework problem, do you have a particular C file you are supposed to be using?
It is easier to parse a compiled object file than a C source file.
It is even easier to use a language like Perl to process the output of an object file parsing tool such as nm.
Is a list of symbols sufficient or do you need to distinguish function and variable names?
Is a list of global names sufficient or do you need to also get the local (static) names?
If you must parse a source file, are you allowed to enforce a no-typedefs rule? Typedefs complicate the source-parsing logic.
Can you parse the output of the C preprocessor or are you required to recognize and deal with macro definitions, macro references, conditional compilation, etc?
Last edited by donbock; Feb 27 '18, 11:20 AM.
Reason: Added note about the preprocessor.
Comment