I try to write POSIX compatible code that is shared between two POSIX compliant operating systems, namely QNX and a Linux variant.
I just found that there are small differences regarding the specification of function return values e.g. of pthread_mutex_trylock()
. One documentation says it returns EOK
(which evaluates to 0
) the other says it returns plain 0
in case of success.
I assume I can safely check return values == 0
or != 0
and avoid the QNX EOK
macro.
My questions:
EOK
(not 0
) POSIX compliant?EOK
part of some standard?0
means success.EOK
equals 0
, then the QNX implementation is POSIX compliant. However, as you already said, use 0
in your own code to ensure it compiles on all platforms.EOK
is more clear, then you can write this in your program:.
#ifndef EOK
#define EOK 0
#endif