如何在编译后创建的二进制文件中插入唯一ID? [英] how to insert unique ID into binary file that created after compilation?

查看:69
本文介绍了如何在编译后创建的二进制文件中插入唯一ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好全部,

如何将独特的ID插入二进制文件(由编译器创建)?

(所以编译之后我可以识别我的src使用)


thx

hello All,
how can i insert unique ID into binary file (that created by compiler)?
(so after compiling i can to identify the src that i use)

thx

推荐答案

文章< 11 ***** *****************@g43g2000cwa.googlegroups .com> ;,

pristo< Ma ******* @ gmail.com>写道:
In article <11**********************@g43g2000cwa.googlegroups .com>,
pristo <Ma*******@gmail.com> wrote:
你好所有,
如何将唯一ID插入二进制文件(由编译器创建)?
(所以编译后我可以识别我使用的src )
hello All,
how can i insert unique ID into binary file (that created by compiler)?
(so after compiling i can to identify the src that i use)




不可携带。不能在这里讨论。 Blah,等等,等等。



Not portable. Can''t discuss it here. Blah, blah, blah.




pristo写于11/08/05 11:36,:


pristo wrote On 11/08/05 11:36,:
hello All,
如何将唯一ID插入二进制文件(由编译器创建)?
(编译后我可以识别我使用的src)
hello All,
how can i insert unique ID into binary file (that created by compiler)?
(so after compiling i can to identify the src that i use)




在便携式C中,你最接近的是用你想要的ID创建

a静态变量。

源文件名,日期和时间通常用于此:


static const char version_info [] =

" @@@ VERSION INFO @@@"

"编译自 __FILE__

"在 __DATE__

"在 __TIME__;


许多系统都有实用程序,可以从可执行文件或目标文件中提取并显示字符串常量,

和分离@@@ VERSION INFO @@@的方法字符串

来自其他人(在Unix系统上,你可以使用`strings''

和`grep'')。可以使用一些源管理系统来提供部分或全部数据,这可以自动化每个文件包含一个版本标识符。

课程,所有这些实用程序都不是C语言的一部分,

并且因系统而异。


这种技术的一个缺点是,一些编译器将会发出有关变量的诊断消息,这些变量是声明但未使用的变量。这样的编译器可能会抱怨

关于`version_info''变量。


-
Er ********* @ sun.com



In portable C, the closest you can come is to create
a static variable initialized with the ID you desire. The
source file name, date, and time are often used for this:

static const char version_info[] =
"@@@ VERSION INFO @@@"
" Compiled from " __FILE__
" on " __DATE__
" at " __TIME__;

Many systems have utilities that can extract and display
the string constants from an executable or object file,
and ways to separate the "@@@ VERSION INFO @@@" strings
from the others (on Unix systems, you could use `strings''
and `grep''). Some source-management systems can be made
to provide part or all of the data, which could automate
the inclusion of a version identifier for each file. Of
course, all such utilities are not part of the C language,
and will vary from system to system.

A disadvantage of this technique is that some compilers
will issue diagnostic messages about variables that are
declared but not used; such compilers are likely to complain
about the `version_info'' variable.

--
Er*********@sun.com


>如何将唯一ID插入二进制文件(由编译器创建)?
>how can i insert unique ID into binary file (that created by compiler)?
(编译后我可以识别我使用的src)
(so after compiling i can to identify the src that i use)




插入ID的一种常用方法是:


static char rcsid [] ="



One common method of inserting an ID is:

static char rcsid[] = "


这篇关于如何在编译后创建的二进制文件中插入唯一ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆