R
R
rakcheevdmitriy2015-10-06 03:41:40
C++ / C#
rakcheevdmitriy, 2015-10-06 03:41:40

How to use define constants when concatenating?

Let there be a code:
#define N n
#define DECODE(q,w,e,r) q ## w ## e ## r
#define START DECODE(m,a,i,N)
Then when concatenating we get START = maiN . I have two questions:
1) Why is the name of the constant N substituted, and not its value (n)?
2) Is it possible to use define constants when concatenating in a code section, as in the example above? To get START = main.
I work in VS 2013.
Please, if you do not answer the question directly, then at least poke your face into the necessary literature to read.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abcd0x00, 2015-10-06
@rakcheevdmitriy

I ask if you do not answer the question directly, then at least poke your face into the necessary literature to read.

www.open-std.org/JTC1/SC22/WG14
You can download the standard there and find the description
6.10.3 Macro replacement
And macros are used for simple replacements, when you need, for example, to insert a piece of code in several places, but it does not pull on a function. That is how they should be considered - as an automated insertion, no more.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question