[mythtv] [mythtv-commits] Ticket #4422: when linking errors occur while loading plugins, the errors are not displayed correctly

Nigel Pearson nigel at ind.tansu.com.au
Sat Jan 5 09:21:15 UTC 2008


> No but a simple mapping of dlerror() to GetLastError() is wrong  
> anyway.
>
> The compat layer should create a dlerror() function that calls
> GetLastError() and then uses FormatMessage() to format the error  
> code into a
> string.

Something like this might work:

inline const char *dlerror(void)
{
     static char errStr[512];
     DWORD       errCode = GetLastError();

     if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
                         FORMAT_MESSAGE_IGNORE_INSERTS |
                         FORMAT_MESSAGE_MAX_WIDTH_MASK,
                         NULL, errCode,
                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                         errStr, 511, NULL))
         sprintf(errStr, "dlopen()/dlsym() caused error %d", errCode);

     return errStr;
}


and if it doesn't, there is always #define dlerror() ""  :-)

--
Nigel Pearson, nigel at ind.tansu.com.au| $50 million worth of
Telstra Net. Eng., Sydney, Australia | hardware and you didn't
Office: 9202 3900    Fax:  9261 3912 | think we'd throw in a GPS?
Mobile: 0408 664435  Home: 9792 6998 |  - Jonas, Bionic Woman




More information about the mythtv-dev mailing list