Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Slightly OT: Compilation question

Reply
Thread Tools

Re: Slightly OT: Compilation question

 
 
Tomás Ó hÉilidhe
Guest
Posts: n/a
 
      06-14-2008
On Jun 13, 12:14*pm, Bit Byte <(E-Mail Removed)> wrote:
> I have some legacy C code that I intend to port over (eventually) to
> C++.



What merit is there in porting code from C to C++?

C is more widely implemented and has more reliable compilers than C++.
By "porting" the code to C++, you're just making it less portable and
less reliable.

If you wanted to take advantage of the extra features in C++, then
that would involve re-writing the code altogether, which means you
should just discard the old code (or at the very least just re-write
the code using the old code as a guide).

If the C code works perfectly, just leave it be and use a compiler
which treats .c and .cpp files properly.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      06-14-2008
Tomás Ó hÉilidhe wrote:
> On Jun 13, 12:14 pm, Bit Byte <(E-Mail Removed)> wrote:
>> I have some legacy C code that I intend to port over (eventually) to
>> C++.

>
>
> What merit is there in porting code from C to C++?
>
> C is more widely implemented and has more reliable compilers than C++.
> By "porting" the code to C++, you're just making it less portable and
> less reliable.
>

Reliable? There's certainly more platforms with compliant C++ compilers
than compliant C99 compilers

> If you wanted to take advantage of the extra features in C++, then
> that would involve re-writing the code altogether, which means you
> should just discard the old code (or at the very least just re-write
> the code using the old code as a guide).
>


What if you want to expand the code with C++ features? A wholesale
rewrite is often unnecessary, the port can be gradual. As I said up
thread (and I've done this a few times): Clean compile as C, add tests,
compile as C++, pass tests, move on.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Tomás Ó hÉilidhe
Guest
Posts: n/a
 
      06-14-2008
On Jun 14, 11:56*pm, Ian Collins <(E-Mail Removed)> wrote:

> What if you want to expand the code with C++ features?



If you wanted to take an object-orientated approach then that would
pretty much mean throwing the C code out the window. Use the C code as
a guide, sure, but that's gone beyond "porting", that's pretty much re-
writing the code differently.


>*A wholesale
> rewrite is often unnecessary, the port can be gradual. *As I said up
> thread (and I've done this a few times): *Clean compile as C, add tests,
> compile as C++, pass tests, move on.



But if the code works perfectly already I don't see why they're going
to the bother of adding C++ features to it? So far I get the feeling
they're changing printf to cout just for the sake of it.

Personally, I'd be delighted if I had C code that did a perfect job
for me, and I'd sooner "port" (or whatever you wanna call it) code
from C++ to C.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      06-14-2008
Tomás Ó hÉilidhe wrote:
> On Jun 14, 11:56 pm, Ian Collins <(E-Mail Removed)> wrote:
>
>> What if you want to expand the code with C++ features?

>
>
> If you wanted to take an object-orientated approach then that would
> pretty much mean throwing the C code out the window. Use the C code as
> a guide, sure, but that's gone beyond "porting", that's pretty much re-
> writing the code differently.
>

What if yo don't? Or if you realises some part would benefit form OO?
>
>> A wholesale
>> rewrite is often unnecessary, the port can be gradual. As I said up
>> thread (and I've done this a few times): Clean compile as C, add tests,
>> compile as C++, pass tests, move on.

>
> But if the code works perfectly already I don't see why they're going
> to the bother of adding C++ features to it? So far I get the feeling
> they're changing printf to cout just for the sake of it.
>

Things change. I've been through this porting process a number of
times, each client had their own valid reasons for doing so. Such a
port isn't a job I'd take on without making sure the client had
realistic expectations.

--
Ian Collins.
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      06-15-2008
Tomás Ó hÉilidhe <(E-Mail Removed)> writes:

> On Jun 13, 12:14Â*pm, Bit Byte <(E-Mail Removed)> wrote:
>> I have some legacy C code that I intend to port over (eventually) to
>> C++.

>
>
> What merit is there in porting code from C to C++?
>


What a ridiculous statement. Are you for real?

> C is more widely implemented and has more reliable compilers than C++.
> By "porting" the code to C++, you're just making it less portable and
> less reliable.


*cough* Bullshit.

> If you wanted to take advantage of the extra features in C++, then
> that would involve re-writing the code altogether, which means you
> should just discard the old code (or at the very least just re-write
> the code using the old code as a guide).


Or just do what he did and ask for experts opinions here ....

> If the C code works perfectly, just leave it be and use a compiler
> which treats .c and .cpp files properly.


Please define properly. Q : are you starting to suck up to the regs
after they savaged you recently?

 
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
Re: Slightly OT: Compilation question Paul Hsieh C++ 16 06-18-2008 07:33 AM
Re: Slightly OT: Compilation question Paul Hsieh C Programming 18 06-18-2008 07:33 AM
Re: Slightly OT: Compilation question Martin Ambuhl C++ 7 06-15-2008 07:51 PM
Re: Slightly OT: Compilation question Martin Ambuhl C Programming 7 06-15-2008 07:51 PM
Re: Slightly OT: Compilation question Tomás Ó hÉilidhe C++ 4 06-15-2008 04:24 AM



Advertisments