如何使gcc忽略从未调用的函数? [英] How to make gcc ignore functions never called?
本文介绍了如何使gcc忽略从未调用的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
void func(){
printf("123\n");
}
int main(){
printf("hi\n");
}
似乎无论我如何编译,func
始终存在于二进制目标中?
It seems no matter how I compile it,func
always exists in the binary target?
推荐答案
默认情况下,函数在C中具有外部链接.将其设为static
应告知链接器外部不需要它,而应将其忽略.
Functions have extern linkage by default in C. Making it static
should inform the linker it's not needed outside and it should leave it out.
这篇关于如何使gcc忽略从未调用的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文