本文介绍了计算#include指令问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一堆条件#include语句,比如


#if PLATFORM ==" LINUX"

#include" LinuxImplementation.h"

#elif PLATFORM ==" WINDOWS"

#include" WindowsImplementation.h"

#elif PLATFORM ==" MACINTOSH"

#include" MacintoshImplementation.h"

#endif


我有什么方法可以使用标准预处理器功能将

转换为单个#include stmt,如


#include< PLATFORM" Implementation.h">


其中''PLATFORM''在Implementation.h之前连接在一起?


我在微软的VC7预处理器上的实验还没有/>
到目前为止成功。

谢谢!


I have a bunch of conditional #include statements like

#if PLATFORM == "LINUX"
#include "LinuxImplementation.h"
#elif PLATFORM ==" WINDOWS"
#include "WindowsImplementation.h"
#elif PLATFORM ==" MACINTOSH"
#include "MacintoshImplementation.h"
#endif

Is there some way I can use the standard preprocessor functionality to
transform this into a single #include stmt like

#include <PLATFORM "Implementation.h">

where ''PLATFORM'' gets concatenated in front of "Implementation.h"?

My experiments with Microsoft''s VC7 preprocessor have not been
successful so far.
Thanks!

推荐答案




提供一个命令行宏类似于


-DPLATFORMIMPL2INCLUDE =" \" LinuxImplementation.h \""


在Linux上和


-DPLATFORMIMPL2INCLUDE =" \" WindowsImplementation.h \"


在Windows上(依此类推),然后执行


#include PLATFORMIMPL2INCLUDE

$ b你的代码中有$ b。


V

-

请通过邮件回复时从我的地址删除资金



Provide a command-line macro that would be different on different
platforms similar to

-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""

on Linux and

-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "

on Windows (and so on), and then do

#include PLATFORMIMPL2INCLUDE

in your code.

V
--
Please remove capital As from my address when replying by mail




提供一个不同的命令行宏在Linux和
上类似于不同的平台--DPLATFORMIMPL2INCLUDE =" \" LinuxImplementation.h \""


-DPLATFORMIMPL2INCLUDE =" \" WindowsImplementation.h \" 在Windows上等等,然后再做

#include PLATFORMIMPL2INCLUDE



Provide a command-line macro that would be different on different
platforms similar to

-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""

on Linux and

-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "

on Windows (and so on), and then do

#include PLATFORMIMPL2INCLUDE




无法'他做的事情如下:


#define HEADER_FILE_NAME PLATFORM" Implementation.h"

#include HEADER_FILE_NAME



Couldn''t he do something like:

#define HEADER_FILE_NAME PLATFORM "Implementation.h"
#include HEADER_FILE_NAME




提供一个不同的命令行宏在Linux和
上类似于不同的平台--DPLATFORMIMPL2INCLUDE =" \" LinuxImplementation.h \""


-DPLATFORMIMPL2INCLUDE =" \" WindowsImplementation.h \" Windows上的

(依此类推),然后做

#include PLATFORMIMPL2INCLUDE



Provide a command-line macro that would be different on different
platforms similar to

-DPLATFORMIMPL2INCLUDE="\"LinuxImplementation.h\""

on Linux and

-DPLATFORMIMPL2INCLUDE="\"WindowsImplementation.h\" "

on Windows (and so on), and then do

#include PLATFORMIMPL2INCLUDE



他不能做类似于:

#define HEADER_FILE_NAME PLATFORM" Implementation.h"
#include HEADER_FILE_NAME



Couldn''t he do something like:

#define HEADER_FILE_NAME PLATFORM "Implementation.h"
#include HEADER_FILE_NAME




我不觉得所以。但请尝试一下,如果你成功了,请告诉我们。


V

-

请删除资金来自通过邮件回复我的地址



I don''t think so. But do try it, and if you succeed, let us know.

V
--
Please remove capital As from my address when replying by mail


这篇关于计算#include指令问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 15:58