조건부로 매크로를 "(a"또는 "b")로 확장하려고하지만 순진한 방법으로 컴파일러 중 하나에서 작동하지 않습니다 (Microsoft C/C++ 및 NDK 컴파일러). 예 :BOOST_PP_IF를 BOOST_PP_LPAREN과 어떻게 조합합니까?
// This works on both compilers, expands to (a) as expected
#define PARENS_AND_SUCH BOOST_PP_IF(1, BOOST_PP_LPAREN() a BOOST_PP_RPAREN(), b)
// MSVC: syntax error/unexpected end of file in macro expansion
// NDK: unterminated argument list
#define PARENS_AND_SUCH BOOST_PP_IF(1, BOOST_PP_LPAREN() a, b)
// Desired expansion: (a
// MSVC expansion: (a, b)
// NDK: error: macro "BOOST_PP_IIF" requires 3 arguments, but only 2 given
#define PARENS_AND_SUCH BOOST_PP_IF(1, BOOST_PP_LPAREN() a, b BOOST_PP_RPAREN())
내가 뭘 잘못하고 있니?
귀하의 문제는 [이 질문에있는 것과 매우 유사하게 보입니다.] (http://stackoverflow.com/questions/24770614/how-do-i-expand-a-macro-containing-commas-inside-a -boost-pp-if). – llonesmiz