Reduce Dependency ?

P

prabhu.desai

I'm compiling a huge(900 files ) embedded application written in C .
Over a period of time , the code has developed a lot of inter crossed
dependenc. The current scenario is , i make a change to one header file
, it begins to compile all the .c files in the project.
Is there a tool/algorithm to remove all the unecessary
dependency ? How do i clean up my code ?

Any help in this regard is highly appreciated.
 
W

Walter Roberson

I'm compiling a huge(900 files ) embedded application written in C .
Over a period of time , the code has developed a lot of inter crossed
dependenc. The current scenario is , i make a change to one header file
, it begins to compile all the .c files in the project.
Is there a tool/algorithm to remove all the unecessary
dependency ?

This is outside of the C standard itself, which does not talk much
about how compiling actually happens.

On Unix-type systems there is often a command named something like
"makedepend". It fishes through the given set of source files and
builds a hierarchy of dependancies, and writes that out in Makefile
format. Most of the time you can set it up so that the Makefile
itself is updated, so that you can

make depends

and it updates the Makefile so that the build goes properly.


Some compilers (SGI IRIX I know; gcc 3 + if I recall correctly) have
this or similar facilities built right into the compilers, so it can
automatically update the configuration file during the compilation phase
itself -- usually quite efficient since it is already looking at all the
source.
 
M

Malcolm

I'm compiling a huge(900 files ) embedded application written in C .
Over a period of time , the code has developed a lot of inter crossed
dependenc. The current scenario is , i make a change to one header file
, it begins to compile all the .c files in the project.
Is there a tool/algorithm to remove all the unecessary
dependency ? How do i clean up my code ?

Any help in this regard is highly appreciated.
It is probably cross-compiled on a compiler that runs on a PC.
So buying a faster PC might be the easiest solution.

Really you need to restructure the code by going through each file one by
one, and reorganising it, placing functions in a pyramid, with as few as
possible at the top depending on everything else, and as many as possible
lower down depending only on the standard library.

However this will be a huge job. I think there might be tools that can help
you, but in the nature of things it cannot be automated.
 
J

Jack Klein

I'm compiling a huge(900 files ) embedded application written in C .
Over a period of time , the code has developed a lot of inter crossed
dependenc. The current scenario is , i make a change to one header file
, it begins to compile all the .c files in the project.
Is there a tool/algorithm to remove all the unecessary
dependency ? How do i clean up my code ?

Any help in this regard is highly appreciated.

I have seen two answers to your question, but I don't think either of
them answers the question that I think you are asking.

A dependency tool, or the dependency generation option of some
compilers, merely lists the includes in the file, then recursively
checks each included file for more includes, until finally it has
listed every file included in the original source once, no matter how
many levels it is nested.

I don't know of any tool that will automatically remove unnecessary
inclusions, but there is one commercial tool that will identify. Then
you need to edit the source and remove the unnecessary ones by hand.

Check out PC Lint at http://www.gimpel.com. It also does a lot of
other vary valuable things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top