机械制造设备类企业网站织梦模板wordpress手机展示
机械制造设备类企业网站织梦模板,wordpress手机展示,wordpress换轮播图的,什么是优化网站通过一些实际项目的开发#xff0c;发现这样一个现象#xff0c;在 Windows 下可以通过指定 __declspec(dllexport) 定义来控制 DLL#xff08;动态链接库#xff09;中哪些函数可以导出#xff0c;暴露给其他程序链接使用#xff0c;哪些函数是 DLL 内部自己使用#x…通过一些实际项目的开发发现这样一个现象在 Windows 下可以通过指定 __declspec(dllexport) 定义来控制 DLL动态链接库中哪些函数可以导出暴露给其他程序链接使用哪些函数是 DLL 内部自己使用而在 Linux 下不存在 dllexport 这样的指示字默认情况下 GCC 编译 SO共享库时把代码中的所有函数都导出了那么如何实现 Windows 下的那种效果由我们自己来控制共享库导出函数呢
其实在 Linux 下也有类似的控制机制。在 GCC 帮助文档中对 -fvisibilitydefault|internal|hidden|protected 参数及其取值有这样一段描述 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 -fvisibilityhidden 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下源文件中的所有函数的 visibility 属性都被默认设置为 public在编译命令中加入 -fvisibilityhidden 参数后会将所有默认的 public 属性变为hidden。此时如果对函数设置 __attribute__((visibility(default))) 参数则该函数按 public 属性处理-fvisibilityhidden 参数不会对该函数起作用。所以针对 GCC 设置了 -fvisibilityhidden 参数之后只有设置了 __attribute__((visibility(default))) 属性的函数才是对外可见的如此则效果等同于 Visual Studio 下的 __declspec(dllexport) 定义。比如
extern int foo(int a, int b, int c) __attribute__((visibility(default)));
这样声明即可。
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/88982.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!