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

            <2014年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(17)

            隨筆分類(138)

            隨筆檔案(137)

            網絡開發

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 499450
            • 排名 - 36

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲中文久久精品无码| 色偷偷888欧美精品久久久| 亚洲va久久久久| 亚洲午夜久久久久妓女影院 | 2021久久精品国产99国产精品| 香蕉久久夜色精品升级完成| 97久久综合精品久久久综合| 四虎亚洲国产成人久久精品| 久久九九免费高清视频| 久久免费国产精品| 久久久久99精品成人片欧美| 久久成人18免费网站| 亚洲精品国产字幕久久不卡 | 一级做a爰片久久毛片看看| 久久发布国产伦子伦精品| 久久久久亚洲AV成人网人人软件| 性欧美大战久久久久久久久| 欧美久久一级内射wwwwww.| 国产精品久久一区二区三区| 国产A三级久久精品| 久久免费99精品国产自在现线 | 99精品久久精品一区二区| 国产福利电影一区二区三区久久久久成人精品综合 | 国产99久久精品一区二区| 国产精品久久久久久久app| 国内精品久久久久久麻豆| 精品国产乱码久久久久久1区2区 | 无码AV波多野结衣久久| 少妇被又大又粗又爽毛片久久黑人| AV色综合久久天堂AV色综合在| 久久无码AV一区二区三区| 久久996热精品xxxx| 久久久久久毛片免费看| AA级片免费看视频久久| 国产精品一区二区久久精品无码 | 精品久久久久久国产| 亚洲国产成人精品久久久国产成人一区二区三区综 | 粉嫩小泬无遮挡久久久久久| 亚洲人成伊人成综合网久久久| 国产精品久久新婚兰兰| 国内精品人妻无码久久久影院导航 |