C++之GNU C的__attribute__((constructor))优先级使用(一百四十九)

news/2024/9/23 7:31:59/

简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!

优质专栏:Audio工程师进阶系列原创干货持续更新中……】🚀

人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.

更多原创,欢迎关注:Android系统攻城狮

欢迎关注Android系统攻城狮

1.前言

本篇目的:理解GNU C的__attribute__ ((constructor))的优先级用法。

<1>.使用方式

注意:构造函数优先级从0100保留,所以使用100以上就可以了,使用100以下给出警告。
使用方式:
__attribute__((constructor(121))) static void test_02(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}__attribute__((constructor(103))) static void test_03(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}

2.应用实例

#include <iostream>
using namespace std;//1.test()在main函数之前调用,它是被系统调用,并非main函数调用.
__attribute__((constructor)) static void test(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}//2.test_01()在main函数之前调用,它是被系统调用,并非main函数调用.
__attribute__((constructor(103))) static void test_01(){//设置优先级为103printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}//3.test_02()在main函数之前调用,它是被系统调用,并非main函数调用.
__attribute__((constructor(101))) static void test_02(){//设置优先级为101printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}//4.test_03()被未调用,因为没有__attribute__((constructor))修饰.
void test_03(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}//4.__attribute__((destructor))修饰析构函数,在析构函数以后执行.
__attribute__((destructor)) void test_04(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);
}class A{
public :A(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);}~A(){printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);}
};int main() {A a;printf("xxx--------->%s, line = %d\n",__FUNCTION__,__LINE__);return 0;
}

http://www.ppmy.cn/news/711667.html

相关文章

iOS开发-- iPhone6 屏幕尺寸

http://www.paintcodeapp.com/news/iphone-6-screens-demystified 转载于:https://www.cnblogs.com/feiling/p/4884486.html

iPhone6和iPhone6 plus的iOS8设计尺寸参考指南

不管怎样&#xff0c;我们要相信土豪还是多的&#xff0c;iPhone6和plus出来后&#xff0c;道长就苦苦追寻iOS8在i6和plus下面的设计尺寸&#xff0c; 百度是找不到的&#xff0c;问过好几个开发群&#xff0c;也没有收获&#xff0c;幸好认识一位加州的伙伴&#xff0c;他给了…

iOS 纯代码适配iPhone6,6p

首先说下让自己的程序支持iPhone6和6&#xff0c;第一种使用官方提供的launch screen.xib&#xff0c;这个直接看官方文档即可&#xff0c;这里不再多述&#xff1b;第二种方法是和之前iPhone5的类似&#xff0c;比较简单&#xff0c;为iPhone6和6添加两张特殊的png iPhone6&a…

关于iPhone屏幕尺寸、分辨率及适配

1.iPhone尺寸规格 设备 iPhone 宽 Width 高 Height 对角线 Diagonal 逻辑分辨率(point) Scale Factor 设备分辨率(pixel) PPI 3GS 2.4 inches (62.1 mm) 4.5 inches (115.5 mm) 3.5-inch 320x480 1x 320x480 163 4(s) 2.31 inches (58.6 mm) 4.5 inches (1…

iPhoneX设计尺寸和适配

被iPhone X刷了一天屏&#xff0c;到下午实在受不了各种假帖。标题写着“iPhone X 适配、指南、设计稿” 内容却是发布会回顾和手机介绍。索性自己去官网找素材写一篇只针对iPhone X适配的贴子&#xff0c;与设计图无关的内容通通不提 昨夜发布的iPhone 8属于常规升级&#xff…

Iphone 66p,IOS8适配工作总结(2015-2-7更新)

一、IOS8适配遇到的问题 1、不能定位 打勾 设置- 隐私-定位服务-你的app-使用应用程序期间(始终) 打开app再进设置后会发现&#xff0c;你打勾的使用程序期间(始终)又给取消了 原来iOS8需要一些方法。 如果需要仅在前台定位,你在调用startUpdatingLocation 前需要调用request…

iphone6、6p设计适配

从知乎转来的&#xff0c;应该是淘宝iOS App适配方案&#xff0c;非常具有参考价值。 移动app开发中多种设备尺寸适配问题&#xff0c;过去只属于Android阵营的头疼事儿&#xff0c;只是很多设计师选择性地忽视android适配问题&#xff0c;只出一套iOS平台设计稿。随着苹果发布…

iphone屏幕尺寸总结

http://blog.csdn.net/phunxm/article/details/42174937#t24 1.iPhone尺寸规格 设备 iPhone 宽 Width 高 Height 对角线 Diagonal 逻辑分辨率(point) Scale Factor 设备分辨率(pixel) PPI 3GS 2.4 inches (62.1 mm) 4.5 inches (115.5 mm) 3.5-inch 320x480 1x …