How to detect QNX version in compilator / preprocessor ?

How to detect QNX version in compilator / preprocessor ?

I’d like to change several parts of code
depending on QNX version (4.2x or 6.3.x):

#ifdef QNX_4
#include <unistd.h> //close()
#include <sys/uio.h> //rd()/wr()
typedef int bool;
#define false 0
#define true 1
#endif

#ifdef QNX_6

#endif

The trick is

#if !defined(QNXNTO) && defined(QNX)
// QNX4 code
#endif

#if defined(QNXNTO) && defined(QNX)
// QNX6 code
#endif

by the way the bool thing, it can be safer to use enum
enum bool { false, true };

should I use QNX ?

I’ve got:

#if defined(QNXNTO) // QNX6 code
n = tcischars(dev_fd);
#else // QNX4 code
n = dev_ischars(dev_fd);
#endif

and it works :slight_smile:

Yes this will working but NOT if you compile the code on non QNX system which is why I added the && defined(QNX). I guess for the second one you don’t need it since if it’s QNXNTO it imply that QNX is defined.

If you know your code is never going to be compile on a non QNX os then you don’t need QNX ;-)