![]() |
|
|
|
#1
|
|||
|
|||
|
Well, if the code yields UB, that needs to be fixed since it violates the C++ standard. This code violates assumptions made by the compiler when reasoning about/optimizing your program - I shouldn't have to get your program to crash. Above reasoning should already convince you that this code needs to be fixed.
Also, I would move the caching outside of the function, or simply use a mutex - these are much faster than people usually assume, and always safe. |
| The Following User Says Thank You to mcp For This Useful Post: | ||
Indigo (07-19-2019) | ||
|
#2
|
|||
|
|||
|
i ve never stated that this is thread safe assuming that it is is wrong.
this snippet is thought as c++ type safe replacement for original post. i agree its not production code where youd better use some loader/lib/functor classes but thats not the purpose of these few lines and neither is original post. its rather for quick testing and only requiring copy&paste a few lines of code. fwiw this aint thread safe either: PHP Code:
|
| The Following User Says Thank You to bugficks For This Useful Post: | ||
Indigo (07-19-2019) | ||
|
#3
|
|||
|
|||
|
It could be changed to GetModuleHandleEx - but there's probably no point in not calling LoadLibrary directly?
|
| The Following User Says Thank You to gigaman For This Useful Post: | ||
Indigo (07-19-2019) | ||
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling any function dynamically without typedef | Succubus | Source Code | 0 | 10-21-2021 16:34 |
| WinAPI: No WM_COMMAND Message? | aldente | General Discussion | 2 | 07-05-2006 07:17 |