Re: [AD] errno_t and strerror_s non-standard types - cmake incorrectly detects strerror_s when not present

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 12/01/2016 01:12 PM, Edgar Reynaldo wrote:
As per cppreference.com it's a C11 function included by string.h. Isn't
Allegro supposed to comply with C90 or C99? C99 is the new default
compile language for MinGW.

C89 is the official requirement, but these days we have quite a few gnu extensions and C99 extensions in use. CMake check is meant to detect it so we can use it whatever standard is in use.

All we need to do is duplicate a string returned by strerror and store
it in userdata->errmsg. strerror_r and strerror_s don't seem necessary.
But it needs to return the string too, without causing a memory leak.

The issue with strerror is that it's not thread safe. We'd need to wrap it up in a mutex. As for the rest, you can just use strncpy into the errmsg, no need to free anything.

-SL




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/