--wrap=xxx (阅读笔记)

随便逛stackoverflow的时候,看到这么一个问题:c++ how to use gcc options --wrap=symbol in class method

--wrap=symbol是干嘛的呢?其实就是可以允许你对标准库中已经定义的函数(假设为symbol)再加一层封装,这样编译器在进行函数调用的解引用的时候,对symbol的解引用会被解析成__wrap_symbol,而如果你要使用真正的标注库里的函数,在调用symbol的时候必须要写成__real_symbol才可以 。

对symbol使用包装函数(wrapper function),任何对symbol未定义的引用(undefined reference)会被解析成__wrap_symbol,而任何对__real_symbol未定义的引用会被解析成symbol。即当一个名为symbol符号使用wrap功能时,工程中任何用到symbol符号的地方实际使用的是__wrap_symbol符号,任何用到__real_symbol的地方实际使用的是真正的symbol。

当然这里面有一些限制条件,比如说:

--wrap首先要让符号定义和符号引用在不同的文件中,否则的话,linker压根就看不到未定义的符号,见2。
另外,文中的代码A::test(),是有语法错误的(因为test又不是static函数,你怎么能A::test()这么写来调用它呢?)。。。

  1. GCC中通过–wrap选项使用包装函数
  2. c++ how to use gcc options --wrap=symbol in class method
  3. 补充
1. -Wl,<options>       Pass comma-separated <options> on to the linker
   		               之前使用过:-Wl,-rpath xxx
   		               此处是这样:-Wl,--wrap=malloc -Wl,--wrap=foo
2. 想要得到1中 -Wl的用法,可以通过gcc -Wl --help 就可以得到具体的用法,并且同时还能得到 -Wa、-Wp等等

<el-col :span="6" :xs="24"> <div class="card-list" style="display: flex;width: 100%;flex-wrap: wrap;justify-content: space-between; align-items: center;"> <!--div style="display: flex; justify-content: space-between; align-items: center;"--> <!--el-card style="margin-bottom:20px; width:300px;height:280px"--> <el-card style="width:300px;height:280px; margin-left:1px;margin-bottom: 10px"> <template #header> <div class="h-4 pl-[90px]" style="width: 100%;display: flex;justify-content: space-between; align-items: center;"> <div class="user-block" style="line-height: 30px;font-size: 20px;"> <span class="username text-muted" style="margin-left: 10px;">故障模拟设备</span> <span class="description" style="margin-left: 10px;">教学理论设备</span> </div> <el-tag class="username text-muted" style="margin-left: 10px;color:green">运行</el-tag> <div class="el-icon-setting" style="font-size: 25px; color: rgba(18, 21, 211, 0.829);" @click="update"></div> </div> </template> <div class="flex justify-center" style="display: flex;width: 100%;flex-wrap: wrap;justify-content: space-between; align-items: center;"> <img class="rightullidiv" :src="'../../../static/images/fan.gif'"> <!--img class="w-[100px] h-[100px] rounded-lg" src="'../../../static/images/fan.gif'" alt=""--> <div class="ml-3" style="width:120px;height:280px; margin-left:1px;margin-bottom: 10px"> <!--el-descriptions class="el-descriptions__body" size="small" :column="Number('1')" border--> <el-descriptions size="small" :column="Number('1')" border> <el-descriptions-item label="电压">380 V</el-descriptions-item> <el-descriptions-item label="电流">10 A</el-descriptions-item> <el-descriptions-item label="通讯">正常 </el-descriptions-item> </el-descriptions> </div> </div> </el-card> </div> </el-col>实现图片与el-descriptions-item label="电压"并排放置,如何修改代码
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值