<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          C++核心準則ES.33:如果必須使用宏定義,命名要有唯一性

          共 1020字,需瀏覽 3分鐘

           ·

          2020-05-05 23:21


          2f585721984cc4108fcbc7294403cf99.webp

          ES.33: If you must use macros, give them unique names

          ES.33:如果必須使用宏定義,命名要有唯一性


          Reason(原因)

          Macros do not obey scope rules.

          宏定義不會遵守作用域準則。


          Example(示例)

          #define MYCHAR        /* BAD, will eventually clash with someone else's MYCHAR*/

          #define ZCORP_CHAR /* Still evil, but less likely to clash */

          Note(注意)

          Avoid macros if you can:?ES.30,?ES.31, and?ES.32. However, there are billions of lines of code littered with macros and a long tradition for using and overusing macros. If you are forced to use macros, use long names and supposedly unique prefixes (e.g., your organization's name) to lower the likelihood of a clash.

          首先是盡量避免使用宏定義,如果可以的參照ES30,31,32中的方法。然而存在數以十億計遍布宏定義的代碼,也長期存在使用和過度使用宏定義的傳統(tǒng)。如果你被迫使用宏定義,使用足夠長的名稱并可以相信存在唯一性的前綴(例如你所屬組織的名稱)以便盡量減低沖突的可能性。


          Enforcement(實施建議)

          Warn against short macro names.

          對短的宏名稱提出警告。


          原文鏈接

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es33-if-you-must-use-macros-give-them-unique-names




          覺得本文有幫助?請分享給更多人。

          關注微信公眾號【面向對象思考】輕松學習每一天!

          面向對象開發(fā),面向對象思考!


          瀏覽 64
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  成人黄片免费网站 | 人妻体体内射精一区二区 | 九九免费视屏 | 18禁 成人黄网站免费视频 | 精品人妻伦一二三区久久春菊成人漫画 |