What about mixing c with c++

This is a discussion on What about mixing c with c++ within the C++ Programming forums, part of the General Programming Boards category; Assume you have a lovely cousin. She write a good program. But--- oh no, she wrote in c language. You ...

  1. #1
    Registered User gandalf_bar's Avatar
    Join Date
    Oct 2003
    Posts
    92

    What about mixing c with c++

    Assume you have a lovely cousin. She write a good program. But--- oh no, she wrote in c language. You hate c. Assume your cousin quit from the job. She become novelist. Now you want to maintain, develop, improve your cousin's program. You are great in C++ but no C. The source code is 6 MB size in zip format. Just think about it... ok....

    What will you do?
    1. Forget it, it is stupidly hard to port c program into c++ program....
    2. port it, rewrite the program into C++.....
    3. Mix it, The base in c, but you improve with new code in c++.....

    What is the reason?
    .................................................. ...........................................
    A man asked, "Who are you?"
    Buddha answered, "I am awaked."

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >1. Forget it, it is stupidly hard to port c program into c++ program....
    It's difficult to convert a proper C program to a proper C++ program, but it's not that hard to make the minor changes needed to compile a C program as C++. Once it compiles as C++ you can add to it easily, but you may find yourself using a lower level subset of C++ unless you want to make more substantial changes.

    >2. port it, rewrite the program into C++.....
    For a large application this could potentially be impractical.

    >3. Mix it, The base in c, but you improve with new code in c++.....
    See my answer to 1.

    >What will you do?
    I would leave the code as C if it wasn't riddled with bugs. But I'm comfortable with C. In your case, you probably know enough of C (from the C subset of C++) to bungle your way through a simple port to get the program to compile as C++, but a large scale redesign and rewrite in C++ might take a lot of time and effort. It depends on what you're willing to put into it.
    My best code is written with the delete key.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,668
    4. Learn C and never look back

    You start with this, if you have some of both
    http://www.parashift.com/c++-faq-lit...c-and-cpp.html

    After that, it depends on say
    If it's working and you don't need to change it, then don't change it
    If it's horribly bugged, and doesn't do a lot of things you would like, rewrite it from scratch.

    Somewhere in between, you should sit back and develop some kind of migration plan, either by making the code C++, or by learning C. 6MB is a lot of code to go converting, and you'll be pretty good at C by the time you're done.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >4. Learn C and never look back
    I vote for this option.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mixing C with C++ code
    By R.Stiltskin in forum C++ Programming
    Replies: 16
    Last Post: 04-25-2009, 11:46 AM
  2. mixing unsigned and signed
    By KIBO in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2009, 03:25 AM
  3. mixing non-specialized and specialized templates
    By m37h0d in forum C++ Programming
    Replies: 6
    Last Post: 12-05-2008, 03:11 PM
  4. Mixing PCM samples - dealing with clicks & overflow
    By jaxen in forum C Programming
    Replies: 11
    Last Post: 05-26-2008, 01:47 PM
  5. Digital mixing in DOS
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 01-11-2002, 07:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21