We have some code originally developed for QNX SDP 6.6 that we are porting to QNX SDP 7.0 (7.1 does not yet have the board support packages we need).
As part of the porting effort, we are finding things that have been removed in 7.1, such as getprio()
to retrieve the process priority. Now I know what that need to be replaced with but, in the interest of minimal impact to the code base, I went looking for a pre-processor variable to indicate whether I'm compiling with SDP 7.0 or something earlier.
That way, I could simply use #ifdef
to select which code to compile, along the lines of __STDC_VERSION__
to figure out which ISO iteration applies.
However, I can't find anything in the QNX docs that seem relevant. I found __QNX__
and __QNXNTO__
which together let me figure out whether it's non-QNX, QNX 4, or QNX Neutrino, but nothing that appears to detect a difference between QNX 6 and 7.
Is there such a beast available?
It appears there is a preprocessor macro for it.
Specifically, you include <sys/neutrino.h>
for QNX 6.6 or 7.0, or <sys/nto_version.h>
for QNX 7.1. I don't have access to others but would expect the scheme to continue.
You can then test _NTO_VERSION
which is defined as VRR
, where V
is the major version and RR
is the revision.
The following transcript shows the relevant header file content:
Cmd> cd ~/qnx_inst
Cmd> rgrep '#define _NTO_VERSION' | grep -v 'Binary file'
qnx660/target/qnx6/usr/include/sys/neutrino.h:#define _NTO_VERSION 660 /* version number * 100 */
qnx700/target/qnx7/usr/include/sys/neutrino.h:#define _NTO_VERSION 700 /* version number * 100 */
qnx710/target/qnx7/usr/include/sys/nto_version.h:#define _NTO_VERSION 710 /* version number * 100 */