__attribute__ ((default)) 和 __attribute__ ((hidden))
制作一个共享库
/* a.h */
int func();
/* a.c */
#include <stdio.h>
#include "a.h" int func()
{
printf("### func ###\n");
return ;
}
gcc -shared -o liba.so a.c -fPIC
main.c
#include "a.h" int main()
{
func();
return
}
gcc -o main main.c -la -L. -Wl,-rpath=.
如果在 func 前面加上
__attribute__((visibility("hidden")))
在编译 main 时,报错:
/tmp/ccbxiXwp.o: In function `main':
main.c:(.text+0x7): undefined reference to `func'
collect2: error: ld returned exit status
如果在编译动态库时加上 -fvisibility=hidden,表示动态库的符号都是 hidden的
在函数前加上 __attribute__((visibility("default"))) 可以使函数对外可见
__attribute__ ((default)) 和 __attribute__ ((hidden))的更多相关文章
- GCC的__attribute__ ((constructor))和__attribute__ ((destructor))
通过一个简单的例子介绍一下gcc的__attribute__ ((constructor))属性的作用.gcc允许为函数设置__attribute__ ((constructor))和__attrib ...
- Linux __attribute__(("hidden"))、default
记录下: Linux下导出so库接口时在下面情况下无法导出(编译时增加了__attribute__(("hidden"))属性). void * __attribute__((&q ...
- [转]GCC系列: __attribute__((visibility("")))
在 objc-api.h 里面有很多关于__attribute__ 的定义. 例如 #if !defined(OBJC_VISIBLE) # if TARGET_OS_WIN32 # if defin ...
- iOS宏和__attribute__
本文目录 iOS宏的经典用法 Apple的习惯 __attribute__ iOS宏的经典用法 1.常量宏.表达式宏 #define kTabBarH (49.0f) #define kScreenH ...
- __attribute__
转来的: http://www.cnblogs.com/astwish/p/3460618.html __attribute__ 你知多少? GNU C 的一大特色就是__attribute__ 机制 ...
- __attribute__ 你知多少?
GNU C 的一大特色就是__attribute__ 机制.__attribute__ 可以设置函数属性(Function Attribute ).变量属性(Variable Attribute )和 ...
- __ATTRIBUTE__ 你知多少?【转】
转自:http://www.cnblogs.com/astwish/p/3460618.html GNU C 的一大特色就是__attribute__ 机制.__attribute__ 可以设置函数属 ...
- __attribute__你知多少(转)
转自:http://www.cnblogs.com/astwish/p/3460618.html GNU C 的一大特色就是__attribute__ 机制.__attribute__ 可以设置函数属 ...
- __ATTRIBUTE__ 知多少?
GNU C 的一大特色就是__attribute__ 机制.__attribute__ 可以设置函数属性(Function Attribute ).变量属性(Variable Attribute )和 ...
随机推荐
- zabbix3.2监控redis
redis的监控 .监控脚本 # vim /usr/local/zabbix_agents_3.2.0/scripts/redismonitor.sh #! /bin/bash #Name: redi ...
- 基于数组的循环队列(C++模板实现)
循环队列使用数组实现的话,简单.方便.之前实现的队列,当尾端索引到达队列最后的时候,无论前面是否还有空间,都不能再添加数据了.循环队列使得队列的存储单元可以循环利用,它需要一个额外的存储单元来判断队列 ...
- 前端 ----jQuery的动画效果
03-jQuery动画效果 jQuery提供的一组网页中常见的动画效果,这些动画是标准的.有规律的效果:同时还提供给我们了自定义动画的功能. 显示动画 方式一: $("div" ...
- [MySQL]子语句的查询技巧
一.统计group by语句的行数 group by语句中,如果包含字段统计函数(诸如:count(),sum()...),这种情况下统计函数只会作用于group by的字段,因此想拿到最终结果的行数 ...
- 用sitemap做主页的菜单栏
首先打开vs--> 新建项-->选择站点地图. 站点地图建好了 其中具体的节点根据自己情况配好就行. 接下来是两个非常重要的类: using System.Collections.Gen ...
- LONG数据类型转换为VARCHAR2并相互转换
--方法1,支持表 --plsql中将long类型隐式转换为varchar2,但是sql不能CREATE OR REPLACE FUNCTION LONG_TO_CHAR( in_rowid rowi ...
- Poco::Crypto--加解密_RSA
Poco::Crypto--加解密(RSA) 1.简单的加解密 Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(R ...
- Synchronizing timer
http://blog.csdn.net/zjq001x/article/details/53107159 集合点: 简单来理解一下,虽然我们的“性能测试”理解为“多用户并发测试”,但真正的并发是不存 ...
- Spring如何使用JdbcTemplate调用存储过程的三种情况
注:原文 <Spring如何使用JdbcTemplate调用存储过程的三种情况 > Spring的SimpleJdbcTemplate将存储过程的调用进行了良好的封装,下面列出使用Jdbc ...
- 配置一个 Confluence 6 环境
本部分对你 Confluence 的外部设置进行描述.包括有如何配置 Web 服务器,应用服务器,目录和文件等信息—— Confluence 运行所需要的所有环境.有关在服务器内部对配置进行修改的内容 ...