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:
- Does POSIX explicitely define which values have to be returned by functions in case of success and/or error?
- Strictly spoken, is a function that is specified to return
EOK(not0) POSIX compliant? - Is
EOKpart of some standard?
0means success.EOKequals0, then the QNX implementation is POSIX compliant. However, as you already said, use0in your own code to ensure it compiles on all platforms.EOKis more clear, then you can write this in your program:.