I could rewrite the macro as follows which eliminates the global static variables and typedefs.
I think this makes the code a lot easier to read and really makes the code reusable.
```
// Define the function as p{NAME} which will be dynamically linked to the library
#define DEFINE_LOCAL_FUNCTION(LIBRARY, RETURN, NAME, ...)                     \
STDAPI_(RETURN) p##NAME(##__VA_ARGS__) {                                      \
    typedef RETURN (WINAPI *pfn##NAME)(##__VA_ARGS__);                        \
    static pfn##NAME ptr##NAME = (pfn##NAME)GetProcAddress(LoadLibrary(_T(LIBRARY)), #NAME); \
    if (ptr##NAME) { return ptr##NAME(##__VA_ARGS__); }                       \
    return (RETURN)(int)TYPE_E_DLLFUNCTIONNOTFOUND;                           \
}
```
From a quick search the above code is already duplicated ~100 times in the whole of mpc-hc project...