什么是 C++ 中的标记字符串?
What is a token string in c++?
The #define creates a macro, which is the association of an identifier
or parameterized identifier with a token string. After the macro is
defined, the compiler can substitute the token string for each
occurrence of the identifier in the source file.
https://docs.microsoft.com/en-ca/cpp/preprocessor/hash-define-directive-c-cpp?view=vs-2017
令人惊讶的是,这个问题并没有被直接问到,而是询问了 tokenization
、tokenizer
、tokening
等。甚至在 DuckDuckGo 上搜索,最接近的问题是在 quora 上问,
我不清楚 string token
和 token string
是否同义。所以要明确一点:
C++ 中的标记字符串是什么?
在这种情况下,令牌字符串 是宏体。在
#defined MAKE_MY_FUNC(x) void x(int bar)
void x(int foo)
部分将被视为 令牌字符串 并且当您使用 MAKE_MY_FUNC
时
MAKE_MY_FUNC(foo){ std::cout << bar; }
然后token string将被替换,代码将被转换为
void foo(int foo){ std::cout << bar; }
你的文章在第二段
中给你他们所谓的token-string
The token-string argument consists of a series of tokens, such as keywords, constants, or complete statements. One or more white-space characters must separate token-string from identifier. This white space is not considered part of the substituted text, nor is any white space that follows the last token of the text.
The #define creates a macro, which is the association of an identifier or parameterized identifier with a token string. After the macro is defined, the compiler can substitute the token string for each occurrence of the identifier in the source file.
https://docs.microsoft.com/en-ca/cpp/preprocessor/hash-define-directive-c-cpp?view=vs-2017
令人惊讶的是,这个问题并没有被直接问到,而是询问了 tokenization
、tokenizer
、tokening
等。甚至在 DuckDuckGo 上搜索,最接近的问题是在 quora 上问,
我不清楚 string token
和 token string
是否同义。所以要明确一点:
C++ 中的标记字符串是什么?
在这种情况下,令牌字符串 是宏体。在
#defined MAKE_MY_FUNC(x) void x(int bar)
void x(int foo)
部分将被视为 令牌字符串 并且当您使用 MAKE_MY_FUNC
时
MAKE_MY_FUNC(foo){ std::cout << bar; }
然后token string将被替换,代码将被转换为
void foo(int foo){ std::cout << bar; }
你的文章在第二段
中给你他们所谓的token-stringThe token-string argument consists of a series of tokens, such as keywords, constants, or complete statements. One or more white-space characters must separate token-string from identifier. This white space is not considered part of the substituted text, nor is any white space that follows the last token of the text.