I am trying to create macro that allows me to simulate behaviour below, but this doesn't work. Is it possible to insert comment characters by macro? What is another option?
#define model_interface(CLASS, ROOT) \
class CLASS : public NInterface<ROOT> { \
private: \
CLASS(CLASS&) { } \
// 'two slashes should be actually inserted too so another characters on same row are ignored'
model_interface(Element, ElementRoot) { // 'previous bracket should be ignored'
// members declarations here
}
I don't think it's possible with the syntax you want, but it's doable with a slightly different one - using parentheses.
This solution uses variadic macros, which is available since C+11, but some compilers supported it well before that.
#define model_interface(CLASS, ROOT, ...) \
class CLASS : public NInterface<ROOT> { \
private: \
CLASS(CLASS&) { } \
__VA_ARGS__ \
}
model_interface(Element, ElementRoot,
// members declarations here
// the variadic part takes care of a comma, e.g.: std::array<int, 3> a;
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With