mirror of https://github.com/oxen-io/lokinet
Avoid strict aliasing warning on function pointers
Cast via an ordinary function pointer rather than a function pointer reference to avoid the warning. Also make the pointer in `Func_t` explicit rather than implicit (deduced into the `Func_t` type) to make it clearer what is going on here.
This commit is contained in:
parent
ef4e720890
commit
58eec9ed11
|
@ -14,12 +14,12 @@ namespace llarp::win32
|
|||
/// throws if the function does not exist in the DLL we openned.
|
||||
template <typename Func_t>
|
||||
void
|
||||
init(std::string name, Func_t& func)
|
||||
init(std::string name, Func_t*& func)
|
||||
{
|
||||
auto ptr = GetProcAddress(m_Handle, name.c_str());
|
||||
if (not ptr)
|
||||
throw win32::error{fmt::format("function '{}' not found", name)};
|
||||
func = reinterpret_cast<Func_t&>(ptr);
|
||||
func = reinterpret_cast<Func_t*>(ptr);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue