新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 控制linux動(dòng)態(tài)鏈接庫導(dǎo)出函數(shù)

        控制linux動(dòng)態(tài)鏈接庫導(dǎo)出函數(shù)

        作者: 時(shí)間:2016-11-22 來源:網(wǎng)絡(luò) 收藏
        linux中,我們可以通過-fvisibility=default|internal|hidden|protected來控制導(dǎo)出函數(shù)

        在GCC幫助文檔 -fvisibility=default|internal|hidden|protected參數(shù)下有這樣一段描述:

        本文引用地址:http://www.104case.com/article/201611/320008.htm

        a superior solution made possible by this option to marking things hidden when the default is public is to make the default hidden and mark things public. This is the norm with DLLs on Windows and with -fvisibility=hidden and "__attribute__ ((visibility("default")))" instead of "__declspec(dllexport)" you get almost identical semantics with identical syntax. This is a great boon to those working with cross-platform projects.

        需要了解的是,在linux下,源文件中的所有函數(shù)都有一個(gè)默認(rèn)的visibility屬性,即為public,在編譯命令中加入 -fvisibility=hidden參數(shù),會(huì)將所有默認(rèn)的public的屬性變?yōu)閔idden。此時(shí),如果對(duì)函數(shù)設(shè)置__attribute__ ((visibility("default")))參數(shù),使特定的函數(shù)仍然按默認(rèn)的public屬性處理,則-fvisibility=hidden參數(shù)不會(huì)對(duì)該函數(shù)起作用。所以,設(shè)置了-fvisibility=hidden參數(shù)之后,只有設(shè)置了__attribute__ ((visibility("default")))的函數(shù)才是對(duì)外可見的。



        評(píng)論


        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 枣庄市| 惠水县| 浠水县| 奉新县| 孝义市| 崇礼县| 无棣县| 小金县| 阳城县| 宁南县| 丽江市| 古交市| 桦南县| 梓潼县| 常宁市| 黎川县| 沈丘县| 庐江县| 霸州市| 东城区| 叙永县| 乐平市| 宽甸| 余庆县| 柳州市| 商都县| 北京市| 栾川县| 宁夏| 台南市| 无为县| 威远县| 澳门| 姜堰市| 定远县| 仪陇县| 连山| 汪清县| 杨浦区| 永新县| 新密市|