What is mean of #name ?
I saw some codes using macro definition to define a function alais. But I don't understand why it put "#" before argument like this :
1 2
|
#define RegisterTcpFlow(name) \
RegisterFlow(#name, &name::Construct, eTcp); \
|
What does #name mean ?
Thanks in advance.
It will give you the name as a string.
RegisterTcpFlow(hello)
will expand to RegisterFlow("hello", &hello::Construct, eTcp);
Thank you for reply. So it means it will convert hello as a variable to a string which is the variable name. Correct ?
You can pass almost anything as argument to a macro, not just variables.
1 2 3 4 5 6 7 8
|
#include <iostream>
#define STR(str) #str
int main()
{
std::cout << STR(This will be turned into a string.\n\t123...);
}
|
This will be turned into a string.
123... |
Last edited on
Topic archived. No new replies allowed.