How to get POSIX strerror_r instead of GNU version?

后端 未结 3 2073
醉话见心
醉话见心 2020-12-16 01:18

How do I get the POSIX strerror_r instead of GNU version?

I\'m compiling with g++ on Ubuntu 8.04 with glibc version 2.7 ( based on what\'s in ).

Edi

3条回答
  •  情书的邮戳
    2020-12-16 02:10

    While it's not required to be thread-safe by the standard, I can't imagine any way a sane person could write a non-thread-safe strerror. What do people do, gunzip the error strings at runtime or something?! A good strerror should be returning a pointer either to string constants in the standard library, or to constant mmap'd memory from the locale messages file.

    Apologies that this isn't a real answer, but if you don't care about absolute theoretical portability you might check and see if all the implementations you care about have sane strerror behavior, and if so, just use that instead.

提交回复
热议问题