ubuntu - How to get POSIX strerror_r instead of GNU version? -


How do I get POSIX instead of the GNU version?

I am compiling Ubuntu with G ++ 8.04 with glibc version 2.7 (depending on what it is). Edit )):

  XSI analog version of strerror_r (), is provided: (_POSIX_C_SOURCE> = 200112L || _XOPEN_SOURCE & gt; = 600) & amp; & Amp; ! _GNU_SOURCE Otherwise, GNU-specific version is provided.  

It says in:

  No feature test macros are clearly defined, after which the following feature defines the test macro by default Are: _BSD_SOURCE, _SVID_SOURCE, _POSIX_SOURCE, and _POSIX_C_SOURCE = 20080 9 L (200112 in L glibc versions 2.10; 199506 L before glibc versions 2.4; 19930 in 9 L glibc versions before 2.1)  

So I should get a POSIX version, but I'm getting GNU instead.

from header string.h :

 There are 2 flavors of the 'Reentent' version of `code2` / * strerror 'Strerror_r', whether the GNU returns the string and can fill the string in the buffer, whether or not using a temporary buffer and POSIX. To use POSIX version, -D_XOPEN_SOURCE = 600 or -D_POSIX_C_SOURCE = 200112L -N-D_GNU_SOURCE is required, otherwise the GNU version is preferred. Note, be careful while using the GNU extension, before turning on the affected headers (or define it) on them ( _GNU_SOURCE ). This strategic). If GNU is not using the extension then there is no need to worry. 

Generally, if GNU is distracted by POSIX in default behavior, you will see some comments to indicate how you can get poses behavior. This is also (usually) documented in the glibc manual, but it does not always make it on the highly condensed man pages.

Edit

Try it Simple Test:

#include & lt; String.h & gt; #ifdef _GNU_SOURCE #error "Some started it!" #endif

Or more directly

  #ifdef _GNU_SOURCE #undef _GNU_SOURCE #endif # include & lt; String.h & gt;  

If _POSIX_C_SOURCE = {version} is defined, then you should be POSIX version, until something else GNU version is not supported due to

The only thing I can think is that it is _GNU_SOURCE . I'm sure it is not on your command line flag, you will be able to see it. It may be that another library that is included in it has turned it on.

I request this request for a POSIX implementation request, even if you are not changing them,

edit

If something is going on _GNU_SOURCE (I do not remember whether it promotes or not, I do not use as much C ++ as I do) , You probably want to allow this to happen. You can use - undef "[macro]" -u [macro] from the command line. However, if that library code looks like this then it will not work:

  #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif # Include & lt; Stdio.h & gt; #include & lt; String.h & gt; #ifdef _GNU_SOURCE #error "this did not work" #endif int main (zero) {return 0; }  

The issue is that when your code actually contains string.h , the extension has been turned on and already in some Has been included. Invoking the guard naturally prevents you from including it twice. Try to explicitly close by including

anything and the first _GNU_SOURCE and string.h . It prevents other libraries from changing those extensions. However, those libraries can not work without them Some codes just expect GNU behavior, and this does not include fallback in POISIX.

I have experience of such frustration with the library code that does not work without asprintf () .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -