动态库版本管理在程序启动和退出时打印so库版本信息
1.代码
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char * argv[])
{
printf("main function\n");
return 0;
}
__attribute__((constructor)) static void beforeFunction()
{
printf("libtest.so version: %s%d\n",__DATA__,__TIME__);
}
__attribute__((destructor)) static void afterFunction()
{
printf("libtest.so version: %s%d\n",__DATA__,__TIME__);
}
编译运行
wanji@wanji-virtual-machine:~/workspace/project/test/VersionPrint$ ./a.out
beforeFunction
main function
afterFunction