K
K
Kirill H2017-10-18 16:10:01
C++ / C#
Kirill H, 2017-10-18 16:10:01

How to process all macro elements?

There is this code:

#define FOO(...) BAR(__VA_ARGS__)
#define BAR(var) int intValue##var##;

The code is not working , because all FOO parameters will be passed to the BAR macro , and it has only 1 as input, but I think the idea is clear (: But if anything ... The bottom line is that there is a FOO macro with an unlimited number of parameters, you need to call the BAR macro for each parameter passed in FOO , what are the ideas? ZY I'm interested in the universal way that an unlimited number of parameters would be accepted as input, it doesn't work in any way.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2017-10-18
@KirillHelm

You can't do a universal variant on macros, IMHO.

V
Vitaly, 2017-10-18
@vt4a2h

There's no way without a macro, right? Just now there are already templates with a variable number of parameters, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question