Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Implementation, Disclose or not?

Reply
Thread Tools

Implementation, Disclose or not?

 
 
thomas
Guest
Posts: n/a
 
      08-17-2010
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.
 
Reply With Quote
 
 
 
 
DDD
Guest
Posts: n/a
 
      08-17-2010


thomas wrote:
> 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.
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      08-17-2010
On 17 aug, 14:51, thomas <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      08-17-2010
On Tue, 2010-08-17, DDD wrote:
>
>
> thomas wrote:
>> 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.


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

>> 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.


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

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Will other Camera manufactures follow Sigma's lead, and disclose more info? George Preddy Digital Photography 25 11-03-2003 11:39 AM
Re: IOS exploit: please disclose vehicle, not mechanism jankemi(remove) Cisco 16 07-25-2003 05:16 PM



Advertisments