Jump to content
 
  • 0
holdmybeer

Best way to integrate foreign code?

Question

I struggle to import a certain feature into my microcontroller project. One of my "init" projects needs an eeprom emulation feature and I found a fitting solution. However, the project comes with a dozen ASF files which might be needed, maybe not. To further complicate things, I don't need their hardware initialization. So I could strip their system init function, which leads to more potentially dead files in the project.

Is there a more convenient way to get an overview of all the dependencies than clicking through all the includes and declarations manually? I have the feeling I don't need most of the files, but the project is a bit too large to rewrite everything.

If I would be very lazy, I'd just throw the whole directory in my project. But I guess this won't end well... So what is your opinion?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

With C it can be very tricky. The linker will resolve the symbols at link time and up until then you cannot trace the dependencies in any easy way. You can try with something that does static code analysis, but if you are using #defines it can be unreliable if you do not get all of the settings correct, especially if some of your #ifdefs depend on things the compiler defines for you.

The best thing you can do is fully explore which files are being used, even if that means removing them one at a time and testing it all out. Always include only the files that you are reallly using, if you have dead code in your project it just makes it harder to understand and that kind of rot just accumulates over time. 

Share this post


Link to post
Share on other sites
  • 0

I've got a tip from a colleague: Doxygen also generates dependency and call graphs for a project. So I ran it and after an hour of tweaking and installing things that Doxygen also requires to run I ended up with a nice graph:

image.thumb.png.f12abb743ecc7cdc54ef9989c25ff175.png

 

It doesn't say if the header is actually used by a module, but it certainly is something to get a quick overview of what I'm about to integrate into my project.

I always thought of Doxygen being a documentation tool, never thought about the possibility to explore an unknown project with that. Very nice!

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Yes Doxygen is great for that, it also allows you to click on the boxes and drill down into the details. I use it for this all of the time!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 


×
×
  • Create New...