Tuesday, October 15, 2013

Macro Expansion

Newsgroup: comp.lang.c++

Subject: Macro Expansion

From: Ryan <code@...>

Date: Tue, 15 Oct 2013 15:38:38 -0700 (PDT)



Below I have a series of defined macros. When ISVALID_TEST is called the compiler is complaining the macro doesn't have enough actual parameters. This means NOINPUT isn't expanding. The definition of ISVALID_TEST uses the UnitTest++ framework. This isn't an issue but unless you have it it won't compile. It is shown here to explain the macro signature.



How can I get NOINPUT to take the place of Kpos, Kvel and Kacc in the macro call instead of all being stuffed into Kpos?



Ryan





#define P99_PROTECT(...) __VA_ARGS__



#define NOINPUT P99PROTECT(false, false, false)



#define ISVALID_TEST(TestName, Kpos, Kvel, Kacc) \

TEST(TestName) \

{ \

point = std::make_shared<KinematicState>(); \

if (Kpos) point->set(position); \

}



//This line complains the macro doesn't have enough actual parameters

ISVALID_TEST(NoInput, NOINPUT);



//Works fine.

ISVALID_TEST(NoInput2, false, false, false);







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?108740-Macro-Expansion&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment