Automatically separate method implementations from their declarations?

  • Thread starter Andreas Schmidt
  • Start date
A

Andreas Schmidt

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
 
P

Pete Vidler

Andreas said:
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
 
D

David Harmon

On Thu, 08 Apr 2004 22:17:56 -0400 in comp.lang.c++, Andreas Schmidt
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.
 

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
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top