Automatically generate C++ file from header?

Michael Aaron Safyan picture Michael Aaron Safyan · Sep 10, 2009 · Viewed 16.6k times · Source

I have a bunch of C++ header files with various class and function declarations. So far, when I've been writing the C++ source file implementations of the declared classes and functions, I've been manually:

  1. Copying the declarations from the header file to the corresponding source file.
  2. Deleting "class classname {" and the matching "};"
  3. Adding "classname::" onto the names of all the class functions.
  4. Replacing the semicolons after the function declarations with "{}".
  5. Deleting the keywords "virtual" and "static".

Only after all that work, which doesn't really do anything, can I actually go about implementing the functions. I am wondering if there is a tool out there somewhere that can automatically generate a ".cpp" file from a ".h" file, where the resulting ".cpp" contains empty stubs for the functions declared in the ".h" file (and for which an inline definition hasn't been given). A UNIX-friendly commandline tool would be preferred. Thanks.

UPDATE: A cross-platform tool would be ideal. If not, I am working on Mac OS X 10.6.

Answer

moonshadow picture moonshadow · Sep 10, 2009

Lazy C++ appears to be designed to address precisely that problem.