区分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对这些宏的定义是如何规范的。

 

转载于:https://www.cnblogs.com/LiuxuLisa/p/3630106.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值