Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 5-2-6 and dynamicaly loading (.dll / .so)
#2
I think the behavior of explicit dynamic linking with dlopen/dlsym is undefined if the function signature does not match:

Code:
int (*ptr)(void) = static_cast(dlsym(handle, "func"));// no way to check the return value e.g. the signature of func
if (ptr != nullptr)
  ptr();// undefined behavior if func is not defined as int func(void) inside the shared object

I would always prefer implicit dynamic linking (e.g. -llibrary) because of the type checking involved.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)