区分debug和release生成文件的名称

通常我们编译工程按照debug和release区分,且明确在Debug版本的生成文件中加入d标记。譬如: HelloWorld.exe 一般是release的生成文件,而debug版叫:HelloWorldd.exe。

 

为了写非绝对名称(好像我们尽可能避免写绝对路径一样),我们使用宏来代替起到此作用。

 

改法1: 【属性界面】(存在问题)

1,【Configuration Properties】->【General】->【Target Name】 : HelloWorld  (若用项目名,则使用$(ProjectName)更好)

2, (debug配置下)【Linker】->【General】->【Output File】: $(OutDir)\$(TargetName)d.exe (在这里加的d)(这里的.exe也可以被其他宏去掉)

出现问题:

arning MSB8012: TargetPath(D:\xx\HelloWorld.exe) does not match the Linker's OutputFile property value (D:\xx\HelloWorldd.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

 

改法2:(更好)

 1, (debug配置下) 在【Target Name】内后缀d,即:【Configuration Properties】->【General】->【Target Name】 : HelloWorldd  (或$(ProjectName)d

2, 掉【Output File】中的后缀d, 即:【Linker】->【General】->【Output File】: $(OutDir)\$(TargetName).exe

 

个人回顾:以前觉得这种内置配置的宏,只要能“拼接对”,怎么都行,现在才有动力想改掉这个一直以来的warning,惭愧。。而且,还没动力知道VS对这些宏的定义是如何规范的。

 

posted @ 2014-03-28 10:35  liuxu_lx7  阅读(359)  评论(0编辑  收藏  举报