• <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
            技術文摘
            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 閱讀(632) 評論(0)  編輯 收藏 引用 所屬分類: vc

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

            常用鏈接

            留言簿(17)

            隨筆分類(138)

            隨筆檔案(137)

            網絡開發

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 499423
            • 排名 - 36

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            精品久久久久久无码人妻热| 99蜜桃臀久久久欧美精品网站| 伊人久久国产免费观看视频| 综合网日日天干夜夜久久| 97精品国产97久久久久久免费 | 伊人丁香狠狠色综合久久| 国产精品美女久久久免费| 无码AV中文字幕久久专区| 亚洲国产精品久久久久婷婷软件| 久久99久久成人免费播放| 中文字幕久久波多野结衣av| 国产精品久久久久影院嫩草| 久久这里都是精品| 91久久精品国产免费直播| 欧美精品国产综合久久| 日韩美女18网站久久精品| 国产69精品久久久久99| 一本色道久久88精品综合| 国产毛片久久久久久国产毛片| 亚洲AV无码久久| 久久99九九国产免费看小说| 色成年激情久久综合| AA级片免费看视频久久| 久久久久亚洲AV无码专区首JN| 久久亚洲AV无码精品色午夜麻豆| 93精91精品国产综合久久香蕉| 91久久婷婷国产综合精品青草| 国产精品乱码久久久久久软件| 久久99精品久久久久久9蜜桃| 国产成人精品久久一区二区三区| 久久久久久免费视频| 久久综合伊人77777麻豆| 久久青青草原亚洲av无码| 久久精品国产亚洲AV嫖农村妇女 | 91精品国产9l久久久久| 久久综合九色综合欧美就去吻| 久久精品9988| 久久精品中文字幕久久| 精品久久久久久亚洲| 国产一区二区三区久久| 99久久免费国产精精品|