用于编译机器的预处理器makro [英] Preprocessor makro for compile machine

查看:96
本文介绍了用于编译机器的预处理器makro的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿那边,



i有一个关于Preprocessor makros的问题。



有没有办法做类似的事情:

 #if COMPUTER_NAME == _T(TestPC)//仅限测试计算机
#importC:\ Path\To\3thParty \ Library
#enve //在我们的开发计算机上
#importD:\Dev \ Path \ Too \ 3rdtharty \ Library
#endif



C:\路径仅限在测试计算机上编译时使用,在所有其他情况下使用D:\路径?



非常感谢你们的帮助! div class =h2_lin>解决方案

是的:最简单的方法是使用

 #IFE DEBUG 

因为你(应该)总是使用debug off f进行编译或者生产版本。


我已经查看了这个问题。你需要做以下事情才能得到你想要的东西。



*在你的试验机上打开VS

*转到:项目 - >属性 - >配置属性 - > C / C ++ - > PreProcessor

*在预处理器定义中添加_TEST_MACHINE

*像这样更改宏

  #if _TEST_MACHINE 
#importC:\ Path \To\3thParty \ Library
#else
#导入D:\Dev \ Path \ Too \ 3thParty \ Library
#endif





请记住不要在你的开发机器的VS上添加_TEST_MACHINE


你不能在预处理器指令中使用字符串办法;请参阅 http://msdn.microsoft.com/en-us/library/ew2hz0yd.aspx [ ^ ]。


Hey out there,

i have a question about Preprocessor makros.

is there a way to do something like:

#if COMPUTER_NAME == _T("TestPC") // only on the test computer
   #import "C:\Path\To\3thParty\Library"
#else // on our dev computers
   #import "D:\Dev\Path\To\3thParty\Libraries" 
#endif


that the "C:\" path is only used, when compile on the test computer and in all other cases the "D:\" path is used?

Thank you so much guys for your help!

解决方案

Yes: the simplest way is to use

#IF DEBUG

as you (should) always compile with debug off for production releases.


I have looked over this issue. You need to do following to get what you want.

* On Your test machine open VS
* Goto: Project->Properties->Configuration Properties->C/C++->PreProcessor
* Add _TEST_MACHINE at the end in Preprocessor Definition
* Change your macro like this

#if _TEST_MACHINE 
   #import "C:\Path\To\3thParty\Library"
#else 
   #import "D:\Dev\Path\To\3thParty\Libraries" 
#endif



Please do remember not to add _TEST_MACHINE on your devlopment machine's VS


No you cannot use strings in preprocessor directives in that way; see http://msdn.microsoft.com/en-us/library/ew2hz0yd.aspx[^].


这篇关于用于编译机器的预处理器makro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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