简体   繁体   English

为什么MFC .rc文件有时有时在末尾手动插入\\ 0?

[英]Why do MFC .rc files sometimes have a manually inserted \0 at the end?

Within this article , I notice that \\0 is inserted into the #define statements for building version strings. 在本文中 ,我注意到在\\ define语句中插入了\\ 0来构建版本字符串。 I've also seen it in some MFC projects that I am maintaining. 在维护的某些MFC项目中,我也看到了它。 While going through the process of moving version resources into a .rc2 file where I can use one header include to setup the versions across all of my projects I've noticed the \\0. 在将版本资源移入.rc2文件的过程中,我可以使用一个标头包括在所有项目中设置版本,我注意到\\ 0。 In some cases it causes no problems, but in some cases the properties window of the resulting compiled file will show a trailing quote ("). Removing the \\0 doesn't seem to hurt anything, but I don't understand why they would ever be needed. Hopefully there are some old school MFC gurus that understand this that can explain whether removing the \\0 is recommended or not. 在某些情况下,它不会造成任何问题,但是在某些情况下,所生成的编译文件的属性窗口将显示尾随引号(“)。删除\\ 0似乎并没有什么坏处,但是我不明白为什么会这样希望有一些古老的MFC专家了解这一点,可以解释是否建议删除\\ 0。

Example: 例:

    VALUE "FileVersion", VERSION_STR"\0" // <-- adding it here causes the version to show in the properties dialog as 1, 0, 4, 1" which is odd.  
    VALUE "InternalName", "DaHelper\0" // <-- what is the \0 for? Isn't it already a string literal null terminated without adding \0?

May be nobody has a real answer for it. 可能没有人对此有真正的答案。

Also the documentation shows no rule for it. 此外,文档中没有任何规定。 The samples in the MSDN (your link) show the same defines, when using strings. 使用字符串时,MSDN (您的链接)中的示例显示相同的定义。 Only a few are shown. 仅显示了一些。 But I rechecked real old sources sind 16bit times. 但是我重新检查了16bit次的真正的旧资源。 It was always the same. 总是一样。 The VALUE types are all terminated by a \\0 character. VALUE类型均以\\ 0字符终止。 Seams that the string defines in the resource editor for this type of resource is not automatically \\0 terminated. 字符串在资源编辑器中为此资源类型定义的接缝不会自动\\ 0终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM