moumou <mo****@igbmc .u-strasbg.fr> writes:
I'm wonderting if it is possible to find a program that takes a C
source code file and split it into multiple files, one per each
function included in the source code ?
I don't know of one (unless you count text editors, but I presume you
want a program that does this automatically).
It probably wouldn't be too difficult to write a program that does
this naively. The job is simpler if you make some assumptions about
how the code is formatted, particularly about the placement of curly
braces. For full generality, the program would have to incorporate a
C parser.
There are programs (such as ctags) that generate lists of symbols
declared in a source file. You might be able to use something like
that as a basis for what you want.
But if the file contains declarations other than function definitions,
each split file won't be able to see those declarations. You might be
able to automatically generate a header containing any global
declarations (not definitions!), but that gets tricky.
--
Keith Thompson (The_Other_Keit h)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.