views:

119

answers:

7

Hi,

I am writing a C program. What I have seen from my earlier experiences is that I make some changes on a correct version of my program, and after that change, the program is computing incorrectly.

Now, for one occasion it may be easy to detect where I made that change and undo it or do it in some other way, and for other occasions I find it hard (with labor) to detect where exactly the problem is.

Can you suggest some platform or tool which allows you to put the new version and old version of the program side by side and mark the changes that were employed on the new version.

I am using gcc 4.3.2 to compile c programs on Ubuntu 10.04 OS.

Any suggestion is welcome.

regards, Anup

+2  A: 

Use a version control system. I recommend Subversion. This will allow you to compare your newer version with the older one to see exactly what changed and you can revert to the older working version if you break your code.

JoshD
A: 

I would do this with some version control system, like Git. Refer to http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide if you're new to version control systems and/or git.

Tumas
A: 

Thats the main purpose of all the version control management software. I recommand to look at Subversion, GIT or Mercurial.

There are thousands of internet resources for this programs.

And they all have good comparision programs integrated in their GUI Tools.

Lothar
+1  A: 

If you want a tiny, small, portable, one-file personal control version system, I can suggest fossil. A documentation is available here.

Benoit
Fossil is cool.
Amigable Clark Kant
A: 

What you are requesting is some diff-like tool. There is a plethora of such tools, ranging from the diff command line utility to GUI frontend such as http://meld.sourceforge.net/. Most of these tools can be combined with (or have counterparts in) revision control systems as Subversion.

Luca Martini
A: 

Also, try to use Git/Mercurial/whatever together with Dropbox, it will allow you to continue developing on other computers. It will also teach you how to collaborate with others and with yourself.

This is slightly easier to do with the newer VCS systems like Git and Mercurial.

buddhabrot
Thanks all, I find the diff utility very useful for my purpose...
anup
A: 

If you would use a version control system, such as Git or Mercurial, and follow a few good practices:

  • committing small, self contained changes (which includes committing, i.e. saving changes to version control, often)
  • committing known good state (or at least trying to, e.g. ensuring that code compiles before you commit)

you would be always able to go back to known good state.

If bug is/was in your current changes, you can compare current state with previous version: somewhere in changed lines there is bug... or something in changed lines uncovered an existing bug.

If bug was introduced by some earlied, unknknown commit, you can use bisect to search through history to find first commit that exhibits given bug: see for example git bisect manpage.

HTH

Jakub Narębski