开发者

How do i "version" a C binary file on linux platforms

usually the prac开发者_运维百科tice is not to include binaries in source control repositories, i am using mercurial, and would like to know if anyone has experience with embedding version (minor + major) in a C Binary, so that when its distributed if i use a command line argument like mybinaryApp --version, i will get a unique version, which i can control at build time.


The way that I embed version numbers in the code is to #define _VERSION_MAJOR in a separate header file, include them in files that need the version number, and then use that macro where needed. Then, you are free to control the version number in a different source file, without having to continually modify the original file.

This is the essence of what most advanced tools do.

Alternatively, if you wanted a build-specific tag, then you can use __DATE__ and __TIME__ to insert build time.


The usual way is to use the autotools (autoconf & automake & autoheader & al.). They make an include file config.h available, and this file defines the PACKAGE_VERSION macro that you can print out with --version.

This process is independent from version control. The simple reason for this is that you will want to distribute your project as a source code tarball, and people have to build that tarball without access to your version control.


Are you looking for something like the KeywordExtension?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜