Automatically separate method implementations from their declarations?

Discussion in 'C++' started by Andreas Schmidt, Apr 9, 2004.

  1. Suppose there is a 10,000 lines header file that wildly mixes definitions
    (the interface) and implementations. Other code that includes this header
    file takes hours to compile, and it's impossible to compile a shared
    library from the header file, of course.

    Is there a tool that takes this header file, and cuts out the
    implementations, writing them into a separate .cc file? It would
    automatically create a clean separation of interface and implementation,
    and so make it possible to compile it into a shared library etc.

    Thanks,
    Andi
     
    Andreas Schmidt, Apr 9, 2004
    #1
    1. Advertising

  2. Andreas Schmidt

    Pete Vidler Guest

    Andreas Schmidt wrote:
    > Suppose there is a 10,000 lines header file that wildly mixes
    > definitions (the interface) and implementations. Other code that
    > includes this header file takes hours to compile, and it's impossible to
    > compile a shared library from the header file, of course.
    >
    > Is there a tool that takes this header file, and cuts out the
    > implementations, writing them into a separate .cc file? It would
    > automatically create a clean separation of interface and implementation,
    > and so make it possible to compile it into a shared library etc.

    [snip]

    I've never heard of such a tool and I can't imagine there being one,
    either. To make a tool that successfully separates interface and
    implementation, it would have to be aware of dependencies, forward
    declarations, etc.

    Writing such a tool properly would be a huge effort for little gain. On
    the other hand if all you want is a separation (and not a clean one),
    you could check out whatever macro/scripting system your editor
    provides. Failing that there's a little thing called cut & paste.

    -- Pete
     
    Pete Vidler, Apr 9, 2004
    #2
    1. Advertising

  3. Andreas Schmidt

    David Harmon Guest

    On Thu, 08 Apr 2004 22:17:56 -0400 in comp.lang.c++, Andreas Schmidt
    <> wrote,
    >Suppose there is a 10,000 lines header file that wildly mixes definitions
    >(the interface) and implementations. Other code that includes this header
    >file takes hours to compile, and it's impossible to compile a shared
    >library from the header file, of course.


    What kind of "implementation"? If it is all templates, it probably has
    to stay in the header, so that it can be instantiated as called for. If
    it is inline functions, I assume someone thought it was a good idea for
    them to be inline and perhaps they were right.

    If it was anything else, I would guess that you would be getting
    "multiple definition" errors.

    >Is there a tool that takes this header file, and cuts out the
    >implementations, writing them into a separate .cc file?


    Not that I have ever heard of. Perhaps it would be not so tough to do a
    quick one time hack, write a program that keys on specific strings in
    your particular file to separate out the parts like you want. But I
    don't really picture what you are dealing with.
     
    David Harmon, Apr 9, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. EvgueniB
    Replies:
    1
    Views:
    648
    Anthony Borla
    Dec 15, 2003
  2. SenderX
    Replies:
    7
    Views:
    381
    Greg Comeau
    Aug 29, 2003
  3. Chris Mantoulidis
    Replies:
    3
    Views:
    416
    Jared Dykstra
    Dec 20, 2003
  4. Frank Fredstone
    Replies:
    1
    Views:
    452
    Jean-Francois Briere
    Jun 27, 2006
  5. Dan Stromberg
    Replies:
    2
    Views:
    403
    Mike Schilling
    Jan 3, 2008
Loading...

Share This Page