• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            aurain
            技術(shù)文摘
            posts - 137,  comments - 268,  trackbacks - 0

            Tells the compiler that the declared global data item (variable or object) is a pick-any COMDAT (a packaged function).


            __declspec( selectany ) declarator
            

            At link time, if multiple definitions of a COMDAT are seen, the linker picks one and discards the rest. If the linker option /OPT:REF (Optimizations) is selected, then COMDAT elimination will occur to remove all the unreferenced data items in the linker output.

            Constructors and assignment by global function or static methods in the declaration do not create a reference and will not prevent /OPT:REF elimination. Side effects from such code should not be depended on when no other references to the data exist.

            For dynamically initialized, global objects, selectany will discard an unreferenced object's initialization code, as well.

            A global data item can normally be initialized only once in an EXE or DLL project. selectany can be used in initializing global data defined by headers, when the same header appears in more than one source file. selectany is available in both the C and C++ compilers.


            //Correct - x1 is initialized and externally visible 
            __declspec(selectany) int x1=1;
            
            //Incorrect - const is by default static in C++, so 
            //x2 is not visible externally (This is OK in C, since
            //const is not by default static in C)
            const __declspec(selectany) int x2 =2;
            
            //Correct - x3 is extern const, so externally visible
            extern const __declspec(selectany) int x3=3;
            
            //Correct - x4 is extern const, so it is externally visible
            extern const int x4;
            const __declspec(selectany) int x4=4;
            
            //Incorrect - __declspec(selectany) is applied to the uninitialized
            //declaration of x5
            extern __declspec(selectany) int x5;
            
            // OK: dynamic initialization of global object
            class X {
            public:
            X(int i){i++;};
            int i;
            };
            
            __declspec(selectany) X x(1);
            

            This code shows how to use the selectany attribute to ensure data COMDAT folding when you also use the /OPT:ICF linker option. Note that data must be marked with selectany and placed in a const (readonly) section. You must explicitly specify the read-only section.

            // selectany2.cpp
            // in the following lines, const marks the variables as read only
            __declspec(selectany) extern const int ix = 5;
            __declspec(selectany) extern const int jx = 5;
            int main() {
               int ij;
               ij = ix + jx;
            }
            

             

            posted on 2013-01-14 00:03 閱讀(622) 評(píng)論(0)  編輯 收藏 引用 所屬分類: vc

            <2013年1月>
            303112345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            常用鏈接

            留言簿(17)

            隨筆分類(138)

            隨筆檔案(137)

            網(wǎng)絡(luò)開發(fā)

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 497600
            • 排名 - 36

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            青青久久精品国产免费看| 久久一本综合| 久久无码AV一区二区三区| 国产日韩欧美久久| 国内精品久久国产大陆| 久久99国产乱子伦精品免费| 亚洲精品无码专区久久久 | 亚洲精品美女久久久久99| 亚洲а∨天堂久久精品9966| 久久天天躁狠狠躁夜夜2020老熟妇| 777久久精品一区二区三区无码| 国产V亚洲V天堂无码久久久| 久久国产精品成人片免费| 久久久无码人妻精品无码| 国内精品九九久久久精品| 国产成人精品久久一区二区三区| 色综合久久久久综合体桃花网| 奇米综合四色77777久久| 亚洲AV日韩精品久久久久久| 蜜臀av性久久久久蜜臀aⅴ| 国产精品无码久久久久久| 日本免费一区二区久久人人澡| 国产精品激情综合久久| 久久99精品久久久久久秒播 | 久久综合久久伊人| 亚洲日韩欧美一区久久久久我 | 女人香蕉久久**毛片精品| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 亚洲精品无码久久久久去q| 久久久久久国产精品无码超碰| 9久久9久久精品| 国产精品亚洲美女久久久| 欧美成人免费观看久久| 麻豆成人久久精品二区三区免费| 亚洲精品高清久久| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久精品九九亚洲精品天堂 | 亚洲国产成人久久一区久久| 久久久久女人精品毛片| 久久99久久无码毛片一区二区| 国产成人久久精品一区二区三区|