Control Linux dynamic link library export Function

Source: Internet
Author: User

Control Linux dynamic link library export Function

In Linux, we can control the export function through-fvisibility = default | internal | hidden | protected.

The GCC help document-fvisibility = default | internal | hidden | protected has the following description:

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 DLL's 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.

In Linux, all functions in the source file have a default visibility attribute, that is, public. Add the-fvisibility = hidden parameter to the compilation command, changes all default public attributes to hidden. In this case, if the _ attribute _ (visibility ("default") parameter is set for the function, the specific function is still processed according to the default public attribute, the-fvisibility = hidden parameter does not work for this function. Therefore, after the-fvisibility = hidden parameter is set, only functions with _ attribute _ (visibility ("default") are visible.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.