Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在pragma中使用宏标记会导致不正确的替换_C++_Visual Studio 2010_Macros_Pragma - Fatal编程技术网

C++ 在pragma中使用宏标记会导致不正确的替换

C++ 在pragma中使用宏标记会导致不正确的替换,c++,visual-studio-2010,macros,pragma,C++,Visual Studio 2010,Macros,Pragma,我试图在VS2010中使用带有“pragma include_alias”的宏,但我得到一个奇怪的编译警告,这意味着替换是不正确的。 代码如下: 18 #define RAPID_INCLUDES_PATH(MY_TARGET_HEADERS) "C:\\thirdpart\\rapidxml-1.13\\" ## #MY_TARGET_HEADERS 19 #define TEST(empty) "C:\\thirdpart\\rapidxml-1.13\\rapidxml_print

我试图在VS2010中使用带有“pragma include_alias”的宏,但我得到一个奇怪的编译警告,这意味着替换是不正确的。 代码如下:

18 #define RAPID_INCLUDES_PATH(MY_TARGET_HEADERS)  "C:\\thirdpart\\rapidxml-1.13\\" ##  #MY_TARGET_HEADERS  
19 #define TEST(empty) "C:\\thirdpart\\rapidxml-1.13\\rapidxml_print.hpp"

//WORKS
21 #pragma include_alias( "rapidxml.hpp",  "C:\\thirdpart\\rapidxml-1.13\\rapidxml.hpp"  )
22 #pragma include_alias( "rapidxml_print.hpp" , TEST(empty) )

//FAILS
23 #pragma include_alias( "rapidxml_utils.hpp" , RAPID_INCLUDES_PATH(rapidxml_utils.hpp) )
24 #pragma include_alias( "rapidxml_iterators.hpp" , RAPID_INCLUDES_PATH(rapidxml_iterators.hpp)   )


26 #include "rapidxml.hpp"
27 #include "rapidxml_iterators.hpp"
28 #include "rapidxml_print.hpp"
29 #include "rapidxml_utils.hpp"
错误消息:

1>  Touching "Debug\xml2.unsuccessfulbuild".
1>ClCompile:
1>  stdafx.cpp
1>d:\workspace\v10\xml2\xml2\stdafx.h(23): warning C4081: expected ')'; found 'string'
1>d:\workspace\v10\xml2\xml2\stdafx.h(24): warning C4081: expected ')'; found 'string'
1>d:\workspace\v10\xml2\xml2\stdafx.h(27): fatal error C1083: Cannot open include file: 'rapidxml_iterators.hpp': No such file or directory
1>
1>Build FAILED.
1>
似乎宏有一些误用。

有人知道怎么修吗?非常感谢。

这真的让我感到害怕,源文件中的绝对路径是一个很大的禁忌,但这显然只是我的意见。事实上,直接在其他包含文件中添加路径可能更合适,但我仍然希望知道不正确替换的原因。在stdafx.cpp上尝试右键单击->属性,然后是C/C++->命令行并将/P(iirc)添加到其他选项?这将为您提供预处理的源文件,该文件应允许您跟踪宏错误扩展到的内容。另一个提示是,
“foo”“bar”
是一个有效的构造,实际上是两个串联的字符串,因此##在这种情况下可能是多余的。谢谢Ylisar!我发现它将生成“C:\\thirdpart\\rapidxml-1.13\\”“rapidxml_utils.hpp”,还有两个额外的报价…嗯