473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Automatically separate method implementations from their declarations?

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
Jul 22 '05 #1
4 1443
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
Jul 22 '05 #2
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
Jul 22 '05 #3
On Thu, 08 Apr 2004 22:17:56 -0400 in comp.lang.c++, Andreas Schmidt
<sc**********@gmx.de> 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.

Jul 22 '05 #4
On Thu, 08 Apr 2004 22:17:56 -0400 in comp.lang.c++, Andreas Schmidt
<sc**********@gmx.de> 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.

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
6
by: Paul Fame | last post by:
Hello World, This is not a flame, but a question about the fundamentals of the language. Unlike some languages, C++ requires class member functions to be declared twice: once in the class...
4
by: Andreas Schmidt | last post by:
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...
6
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
1
by: sieg1974 | last post by:
Hi, I'm a beginner with c++ programming, and came across the following code. I have the following hierarchy of classes where both CLASS_A_PARENT and CLASS_B_PARENT extend MAIN. MAIN...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
88
by: William Krick | last post by:
I'm currently evaluating two implementations of a case insensitive string comparison function to replace the non-ANSI stricmp(). Both of the implementations below seem to work fine but I'm...
3
by: Bruce One | last post by:
Does anyone know a way to make the IDE close braces in Ifs statements (methods also) for C# ? In VB.NET you have an automatic closing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.