I'm on Ubuntu 10.04 using GCC and I want to use the TEMP_FAILURE_RETRY macro as described here:
http://www.gnu.org/s/hello/manual/libc/Interrupted-Primitives.html
However, when compiling, I received the following error:
undefined reference to `TEMP_FAILURE_RETRY'
I looked in unistd.h where the macro is defined and preceded by:
#ifdef __USE_GNU
How do I get my code to compile and use this macro? Is it possible to just wrap it with the same #ifdef __USE_GNU in my code?
__USE_GNU is an internal macro, so you should not define it yourself.
__USE_GNU
But you can define _GNU_SOURCEeither in your code or during compilation (using the parameter -D).
_GNU_SOURCE
-D
, TEMP_FAILURE_RETRY .
TEMP_FAILURE_RETRY
_GNU_SOURCE , TEMP_FAILURE_RETRY. TEMP_FAILURE_RETRY, , C, GNU:
#define CALL_RETRY(retvar, expression) do { \ retvar = (expression); \ } while (retvar == -1 && errno == EINTR);
retvar , .
retvar