#pragma注释(lib的预处理程序宏) [英] preprocessor macro for #pragma comment(lib

查看:76
本文介绍了#pragma注释(lib的预处理程序宏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码

Preprocessor.h
__________________________________
#define Stringize_It(__ X)#__X
#ifdef _DEBUG
#define lib_dir(__ X)Stringize_It(C:/Addins/Debug/__ X)
#else
#define lib_dir(__ X)Stringize_It(C:/Addins/Release/__ X)
#endif

XYZ.h
__________________________________
#pragma comment(lib,lib_dir(XYZ.lib))


当我在另一个项目中包含XYZ.h时,它对于前十二个项目都可以完美运行,但最终失败.在这种情况下,就像预处理器宏Stringize_It尚未定义.

可能是什么问题?我正在使用Visual C ++.

我知道我可以简单地使用
#ifdef _DEBUG
#pragma comment(lib,"C:/Addins/Debug/XYZ.lib")
#else

#pragma comment(lib,"C:/Addins/Release/XYZ.lib")
#endif

但是,使用起来比较烦人,并且需要花费更多的工作来更改路径.

I am trying to use the following code

Preprocessor.h
__________________________________
#define Stringize_It(__X) #__X
#ifdef _DEBUG
#define lib_dir(__X) Stringize_It( C:/Addins/Debug/__X)
#else
#define lib_dir(__X) Stringize_It( C:/Addins/Release/__X)
#endif

XYZ.h
__________________________________
#pragma comment(lib, lib_dir(XYZ.lib))


When I include XYZ.h in another project, it works perfectly for the first dozen projects but eventually fails. In that case, it''s like the preprocessor macro Stringize_It has been undefined.

What might be the problem? I am using Visual C++.

I know that I can simply use
#ifdef _DEBUG
#pragma comment(lib, "C:/Addins/Debug/XYZ.lib")
#else

#pragma comment(lib, "C:/Addins/Release/XYZ.lib")
#endif

However, that is more annoying to use and takes a lot more work to change paths.

推荐答案

由于最终失败,我的意思是它不适用于所有我的C ++项目.
By it eventually fails, I mean that it does not work for all of my C++ projects.


这篇关于#pragma注释(lib的预处理程序宏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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