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

            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(17)

            隨筆分類(138)

            隨筆檔案(137)

            網絡開發

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 498811
            • 排名 - 36

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            中文成人无码精品久久久不卡| 国产成人无码久久久精品一| 久久综合伊人77777| 狠狠色丁香久久婷婷综合图片| 狠狠色婷婷久久综合频道日韩| 69久久精品无码一区二区| 久久精品女人天堂AV麻| 久久亚洲私人国产精品| 久久久免费观成人影院| 国产午夜精品久久久久免费视| 久久影院亚洲一区| 99久久综合狠狠综合久久止| 亚洲人成网站999久久久综合| 韩国免费A级毛片久久| 久久精品国产乱子伦| 国产精品成人久久久久三级午夜电影| 久久久久av无码免费网| 久久99精品国产麻豆蜜芽| …久久精品99久久香蕉国产| 亚洲精品tv久久久久| 久久精品国产只有精品66| 欧美777精品久久久久网| 精品久久久久久无码中文字幕一区 | 亚洲一区精品伊人久久伊人| 亚洲国产精品久久久久| 精品国产VA久久久久久久冰| 亚洲国产精品18久久久久久| 无码国内精品久久综合88| 久久久久亚洲?V成人无码| 91精品日韩人妻无码久久不卡| 久久精品99久久香蕉国产色戒| 99久久国产精品免费一区二区| 精品国产青草久久久久福利| 精品国产乱码久久久久久呢 | 久久久久成人精品无码| www亚洲欲色成人久久精品| 久久噜噜电影你懂的| 精品国产青草久久久久福利| 久久久精品日本一区二区三区| 无码人妻少妇久久中文字幕| 久久综合色老色|