【发布时间】:2019-09-24 22:51:09
【问题描述】:
我有一个提供函数 func() 的库:
return_type func(type arg);
有必要在我的应用程序中通过我自己的实现来覆盖它。这是可能的,因为库提供了一个弱符号 func 而我的应用程序中的 func 符号是一个强符号。 (这是我的理解。)
现在我希望能够调用 func 的两个实现 - 库的实现和我自己的实现:
// The problem is that the names are the same.
func(); // Everything is OK, calling my implementation (in my application)
func(); // How can I call library's implementation now?
我可以调用我的实现,因为它覆盖了库中的实现。但是我怎样才能调用库中的实现呢?怎么参考?
【问题讨论】:
-
您应该查看 GNU ld 的
-wrap选项,看看它是否可以帮助您
标签: c++ linux linker shared-libraries