• <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

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

            常用鏈接

            留言簿(17)

            隨筆分類(138)

            隨筆檔案(137)

            網絡開發

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 498815
            • 排名 - 36

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            区久久AAA片69亚洲| 久久九九兔免费精品6| 久久精品一区二区国产| 国产精品女同久久久久电影院| 久久久久免费看成人影片| 久久九九有精品国产23百花影院| 青青草原综合久久大伊人精品| 青青青青久久精品国产h久久精品五福影院1421 | 精品久久久久久久无码| 国产精品成人精品久久久| 伊人色综合久久天天网| 日本精品久久久久中文字幕| 亚洲国产日韩欧美久久| 久久99国产精一区二区三区| 久久人做人爽一区二区三区| 国内精品久久久久久中文字幕| 亚洲人成网亚洲欧洲无码久久| 国产AV影片久久久久久| 久久久婷婷五月亚洲97号色| 久久综合亚洲色HEZYO国产| 国产精品99久久久久久人| 国产精品久久久久久久app| 9191精品国产免费久久| 久久99久久99精品免视看动漫| 亚洲人AV永久一区二区三区久久| 青青草原综合久久| 久久99国产精品久久99果冻传媒| 久久精品一本到99热免费| 一本一本久久A久久综合精品| 天天影视色香欲综合久久| 久久精品国产福利国产琪琪| 国产日韩欧美久久| 亚洲嫩草影院久久精品| 99久久99久久精品国产片果冻| 久久99国产综合精品女同| 久久午夜无码鲁丝片| 亚洲AV日韩精品久久久久久| 久久中文字幕人妻丝袜| 亚洲国产精品无码久久久秋霞2| 性做久久久久久久| 久久se精品一区精品二区|