Implementation, Disclose or not?

T

thomas

Hi,

I have a header file like this:
-------------------MyStruct.h---------
struct MyStruct{
void method1();
};
------------------MyStruct.cpp----------
void MyStruct::method1(){}

Now I will use MyStruct in several projects.
Definitely I will include "MyStruct.h" in each project.
But I don't know how to handle "MyStruct.cpp".

I think there are several options:
1. compile MyStruct.cpp in a library, link it when building other
projects.
But there is only one "cpp", it seems over-kill.
2. compile MyStruct.cpp in one of the project, link the project when
building other projects.
But it seems ugly. There's no obvious dependence between the projects.
3. put one copy of MyStruct.cpp in each project.
It's obviously ugly as to maintenance difficulty.

Now I want to hear your suggestions, thanks.
 
D

DDD

thomas said:
Hi,

I have a header file like this:
-------------------MyStruct.h---------
struct MyStruct{
void method1();
};
------------------MyStruct.cpp----------
void MyStruct::method1(){}

Now I will use MyStruct in several projects.
Definitely I will include "MyStruct.h" in each project.
But I don't know how to handle "MyStruct.cpp".

I think there are several options:
1. compile MyStruct.cpp in a library, link it when building other
projects.
But there is only one "cpp", it seems over-kill.
2. compile MyStruct.cpp in one of the project, link the project when
building other projects.
But it seems ugly. There's no obvious dependence between the projects.
3. put one copy of MyStruct.cpp in each project.
It's obviously ugly as to maintenance difficulty.

Now I want to hear your suggestions, thanks.

If you think the 1st option seems over-kill, why not putting the
MyStruct.cpp in another more big library.
 
Ö

Öö Tiib

Hi,

I have a header file like this:
-------------------MyStruct.h---------
struct MyStruct{
    void method1();};

------------------MyStruct.cpp----------
void MyStruct::method1(){}

Now I will use MyStruct in several projects.
Definitely I will include "MyStruct.h" in each project.
But I don't know how to handle "MyStruct.cpp".

I think there are several options:
1. compile MyStruct.cpp in a library, link it when building other
projects.
But there is only one "cpp", it seems over-kill.
2. compile MyStruct.cpp in one of the project, link the project when
building other projects.
But it seems ugly. There's no obvious dependence between the projects.
3. put one copy of MyStruct.cpp in each project.
It's obviously ugly as to maintenance difficulty.

Now I want to hear your suggestions, thanks.

Number of .h and .cpp files should not matter at all when considering
if to make it library or not.

For example SQLite. It is one of the most widely used SQL database
engines and it is made available as single ANSI C source file. It is
not developed as one source file but it is merged to one to speed up
its compiling time.

How to make modules/libraries/packages involves bit more than just
throwing some cpp files together.
 
J

Jorgen Grahn

Do you mean #include, or include as in copy, as in "point out", or what?
I see no reason not to treat it just like MyStruct.cpp
If you think the 1st option seems over-kill, why not putting the
MyStruct.cpp in another more big library.

Keeping an ever-growing "utilities" library isn't much fun either --
I suspect it will become unwieldy and of varying quality.

I'd go for (3). Make a copy in each project which uses it. With
version control you can tell where the code originated, and notice if
one of them got bug-fixes which others will want too. Or, you can
tear it apart and rework it within project A if needed, without
affecting project B.

/Jorgen
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top