<small id='2lLd7'></small><noframes id='2lLd7'>

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

          <bdo id='2lLd7'></bdo><ul id='2lLd7'></ul>
      3. 如何在 gcc 命令行中定义字符串文字?

        时间:2023-09-18
        <tfoot id='uDE9p'></tfoot>

        1. <small id='uDE9p'></small><noframes id='uDE9p'>

        2. <legend id='uDE9p'><style id='uDE9p'><dir id='uDE9p'><q id='uDE9p'></q></dir></style></legend>

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

                    <tbody id='uDE9p'></tbody>
                  本文介绍了如何在 gcc 命令行中定义字符串文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在gcc命令行中,我想定义一个字符串比如-Dname=Mary,然后在源代码中我想要printf("%s", name); 打印Mary.
                  我怎么办?

                  In gcc command line, I want to define a string such as -Dname=Mary, then in the source code I want printf("%s", name); to print Mary.
                  How could I do it?

                  推荐答案

                  两个选项.首先,对引号进行转义,这样 shell 就不会吃掉它们:

                  Two options. First, escape the quotation marks so the shell doesn't eat them:

                  gcc -Dname="Mary"
                  

                  或者,如果你真的想要 -Dname=Mary,你可以将它字符串化,虽然它有点 hacky.

                  Or, if you really want -Dname=Mary, you can stringize it, though it's a bit hacky.

                  #include <stdio.h>
                  
                  #define STRINGIZE(x) #x
                  #define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
                  
                  
                  int main(int argc, char *argv[])
                  {
                      printf("%s", STRINGIZE_VALUE_OF(name));
                  }
                  

                  请注意,STRINGIZE_VALUE_OF 会很高兴地评估到宏的最终定义.

                  Note that STRINGIZE_VALUE_OF will happily evaluate down to the final definition of a macro.

                  这篇关于如何在 gcc 命令行中定义字符串文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:我可以将普通文件链接到我的可执行文件中吗? 下一篇:GCC 配置文件引导优化 (PGO) 收集哪些信息以及哪些

                  相关文章

                  最新文章

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

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

                      <tfoot id='ArENR'></tfoot>