Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
extern调用函数与调用函数之间通常在性能上存在差异static吗?如果是这样,是什么导致了这种差异——两个调用不是通过早期绑定以相同的方式映射(即到特定的机器地址)吗?
extern
static
这是一个实现细节,完全取决于编译器/链接器。在 Linux 上,在静态链接库中调用静态函数或外部函数本质上是相同的,而在共享库中调用函数会增加一层间接性,因此速度会慢一些。
此外,编译器有更多关于静态函数的信息,因此可以进行更多优化,包括潜在的内联。