New Projects - Fresh from the Labs

deheader—C Header Analysis (www.catb.org/~esr/deheader)

In a world of ever-expanding code, it's easy to become sloppy, with lines of redundant code or inelegant design coming into play. Thankfully, deheader steps up to the plate—a simple tool that can save coders a great deal of time.

According to the Web site: “deheader analyzes C and C++ files to determine which header inclusions can be removed while still allowing them to compile. This may result in substantial improvements in compilation time, especially on large C++ projects; it also sometimes exposes dependencies and cohesions of which developers were unaware.”

deheader scans code for redundant header inclusions. Here's some output from the MPlayer Project, for instance.

Installation and Usage

As far as packages go, at the time of this writing, the only thing available was a source tarball. But, fear not. No compiling is necessary, and because there's no real mention of library requirements, I'm guessing most distros will run it off the bat, assuming they have Python.

Download the latest tarball from the Web site, extract it, and open a terminal in the new folder. Then, it's simply a case of running:

$ ./deheader path-of-files

If the given path is a directory, deheader scans all the files within. Give it some time to process, and eventually a list of all the unnecessary headers appears on-screen. For instance, I chose to analyze the now ten-year-old MPlayer code, a project that would unavoidably have a lot of legacy code and loose ends simply from being around for such a long time.

If you're ready to take things further, add a switch of -r, and the unnecessary headers are removed from the files. If you want to do some test compiling, use the -m switch. As an example, here's a command I ran against the MPlayer code:

$ ./deheader -r  ~/src/mplayer-export-2010-12-27/ 

Those are the basics; refer to the documentation for more information.

As you can see, deheader is a very simple-to-use program with an elegant design. This ideal of coding elegance is manifest in deheader's results. It should save a great deal of compilation time and highlight coding foibles that likely would have remained unnoticed. Although it's still sitting around in tarball source form, hopefully it will make its way into distro repositories soon.

John Knight is a 26-year-old, drumming- and climbing-obsessed maniac from the world's most isolated city—Perth, Western Australia. He can usually be found either buried in an Audacity screen or thrashing a kick-drum beyond recognition.

______________________

John Knight is the New Projects columnist for Linux Journal.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix