<i id='6ZIxJ'><tr id='6ZIxJ'><dt id='6ZIxJ'><q id='6ZIxJ'><span id='6ZIxJ'><b id='6ZIxJ'><form id='6ZIxJ'><ins id='6ZIxJ'></ins><ul id='6ZIxJ'></ul><sub id='6ZIxJ'></sub></form><legend id='6ZIxJ'></legend><bdo id='6ZIxJ'><pre id='6ZIxJ'><center id='6ZIxJ'></center></pre></bdo></b><th id='6ZIxJ'></th></span></q></dt></tr></i><div id='6ZIxJ'><tfoot id='6ZIxJ'></tfoot><dl id='6ZIxJ'><fieldset id='6ZIxJ'></fieldset></dl></div>
  1. <tfoot id='6ZIxJ'></tfoot>

      • <bdo id='6ZIxJ'></bdo><ul id='6ZIxJ'></ul>

    1. <small id='6ZIxJ'></small><noframes id='6ZIxJ'>

      <legend id='6ZIxJ'><style id='6ZIxJ'><dir id='6ZIxJ'><q id='6ZIxJ'></q></dir></style></legend>

    2. 在 VC 2015 上使用带有字符串的宏失败

      Using macro with string fails on VC 2015(在 VC 2015 上使用带有字符串的宏失败)
    3. <small id='nYV2d'></small><noframes id='nYV2d'>

          <tbody id='nYV2d'></tbody>
        <i id='nYV2d'><tr id='nYV2d'><dt id='nYV2d'><q id='nYV2d'><span id='nYV2d'><b id='nYV2d'><form id='nYV2d'><ins id='nYV2d'></ins><ul id='nYV2d'></ul><sub id='nYV2d'></sub></form><legend id='nYV2d'></legend><bdo id='nYV2d'><pre id='nYV2d'><center id='nYV2d'></center></pre></bdo></b><th id='nYV2d'></th></span></q></dt></tr></i><div id='nYV2d'><tfoot id='nYV2d'></tfoot><dl id='nYV2d'><fieldset id='nYV2d'></fieldset></dl></div>

            <tfoot id='nYV2d'></tfoot><legend id='nYV2d'><style id='nYV2d'><dir id='nYV2d'><q id='nYV2d'></q></dir></style></legend>
                <bdo id='nYV2d'></bdo><ul id='nYV2d'></ul>

              • 本文介绍了在 VC 2015 上使用带有字符串的宏失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                为什么编译失败?

                char programDate[] = "("__DATE__")";
                

                但这编译得很好(见空间):

                But this compiles fine (see space):

                char programDate[] = "(" __DATE__")";
                

                我知道 VC2015 现在支持文字运算符.但这不应该在编译阶段吗?__DATE__ 应该已经被预处理器处理了.这是怎么回事?

                I do know VC2015 now supports literal-operators. But shouldn't that be in compilation phase? __DATE__ should have been processed by the pre-processor. What is going on here?

                我想到了一些 Unicode/非 Unicode 构建的混合匹配问题 - 但它没有帮助.这不仅是预定义宏的问题,还有用户定义的问题:

                I thought of some mix-match issue with Unicode/non-Unicode build - but it doesn't help. It's not just issue with pre-defined macros, but with user defined also:

                #define MACRO "abc"
                char data[] = "("MACRO")";
                

                Error C3688 invalid literal suffix '__DATE__'; literal operator or literal operator template 'operator ""__DATE__' not found
                

                推荐答案

                从 C++11 开始,用户定义的文字就存在并且是预处理的一部分.语法是:

                Since C++11, user-defined literals exist and are part of preprocessing. The grammar is:

                preprocessing-token:
                    user-defined-string-literal
                    // other stuff...
                
                user-defined-string-literal:
                    string_literal ud-suffix
                
                ud-suffix:
                    identifier
                

                所以 "("__DATE__ 匹配 preprocessing-token,但 "(" __DATE__ 不匹配 (那是两个单独的预处理标记).

                So "("__DATE__ matches preprocessing-token, but "(" __DATE__ doesn't (that is two separate preprocessing tokens).

                宏替换发生在标记化之后.由于您的第一个示例中没有标记 __DATE__,因此没有替换.

                Macro replacement happens after tokenization. Since there is no token __DATE__ in your first example, there is no replacement.

                这篇关于在 VC 2015 上使用带有字符串的宏失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                  1. <legend id='eZOMt'><style id='eZOMt'><dir id='eZOMt'><q id='eZOMt'></q></dir></style></legend>

                    <small id='eZOMt'></small><noframes id='eZOMt'>

                    <tfoot id='eZOMt'></tfoot>

                          <bdo id='eZOMt'></bdo><ul id='eZOMt'></ul>
                          <i id='eZOMt'><tr id='eZOMt'><dt id='eZOMt'><q id='eZOMt'><span id='eZOMt'><b id='eZOMt'><form id='eZOMt'><ins id='eZOMt'></ins><ul id='eZOMt'></ul><sub id='eZOMt'></sub></form><legend id='eZOMt'></legend><bdo id='eZOMt'><pre id='eZOMt'><center id='eZOMt'></center></pre></bdo></b><th id='eZOMt'></th></span></q></dt></tr></i><div id='eZOMt'><tfoot id='eZOMt'></tfoot><dl id='eZOMt'><fieldset id='eZOMt'></fieldset></dl></div>
                            <tbody id='eZOMt'></tbody>