程序开发
我正在写一个C程序。从我之前的经验来看,我对程序的正确版本进行了一些更改,而在更改之后,程序计算不正确。
现在,在某些情况下,可能很容易检测到我在哪里进行了更改并撤消它或以其他方式进行更改,而在其他情况下,我发现很难(费力)检测到问题到底出在哪里。
您能否建议一些平台或工具,它允许您将程序的新版本和旧版本并排放置,并标记新版本上采用的更改。
我正在使用 gcc 4.3.2 在 Ubuntu 10.04 操作系统上编译 c 程序。
欢迎任何建议。
问候, 阿努普
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
使用版本控制系统。我推荐颠覆。这将允许您将新版本与旧版本进行比较,以准确了解发生了什么变化,并且如果您破坏了代码,您可以恢复到旧的工作版本。
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.
如果你想要一个微型、小型、便携、单文件的个人控制版本系统,我可以建议fossil。此处提供文档。
If you want a tiny, small, portable, one-file personal control version system, I can suggest fossil. A documentation is available here.
您所要求的是一些类似 diff 的工具。此类工具有很多,从
diff
命令行实用程序到 GUI 前端,例如 http ://meld.sourceforge.net/。这些工具中的大多数都可以与 Subversion 等版本控制系统结合使用(或在其中拥有对应工具)。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.我会使用一些版本控制系统来做到这一点,例如Git。如果您是,请参阅Git 初学者:权威实用指南版本控制系统和/或 git 的新手。
I would do this with some version control system, like Git. Refer to Git for beginners: The definitive practical guide if you're new to version control systems and/or git.
这就是所有版本控制管理软件的主要目的。
我建议查看 Subversion、GIT 或 Mercurial。
该程序有数千个互联网资源。
他们的 GUI 工具中都集成了很好的比较程序。
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.
另外,尝试将 Git/Mercurial/其他任何东西与 Dropbox 一起使用,它将允许您继续在其他计算机上进行开发。它还将教您如何与他人以及与自己合作。
使用 Git 和 Mercurial 等较新的 VCS 系统,这会稍微容易一些。
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.
如果您使用版本控制系统,例如Git或Mercurial,并遵循一些良好实践:
您将始终能够返回到已知的良好状态。
如果错误存在于您当前的更改中,您可以将当前状态与以前的版本进行比较:更改的行中的某处存在错误...或者更改的行中的某些内容发现了现有的错误。
如果 bug 是由某些早期的、未知的提交引入的,您可以使用 bisect 搜索历史记录以查找显示给定 bug 的第一个提交:例如,请参阅
git bisect
联机帮助页。华泰
If you would use a version control system, such as Git or Mercurial, and follow a few good practices:
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