'far' not supported in QNX 6.3?

Hello QNX lovers,

I 've trouble to remove ‘far’ from this source code. I try to convert to QNX 6.3 application. I 'm just new to QNX.
Any body can help me?

typedef pid_t (far *INT_HAND)(void); /far not support/
#define DEC_INT_HAND(PH) static pid_t far PH(void)

Thanks
arms

#define far

That outta do it.

Thanks mario for quick reply. There more problem with QNX neutrino, some function which is ommon to the c/c++ programming no logger support anymore. Some of it:

/* MIG4NTO kbhit Use tcischars() instead. /
/
MIG4NTO getch Do a read() with echo off. */
if (kbhit() && getch() == 0x1b)
return 0;

Could you please give me converting code to QNX 6.30?
Anyone? Plz…

Well they may be “common” but they are non standard functions. They are not part of the C or C++ standard nor of any standard for that matter. If you look at the QNX4 documentation you will notice these 2 functions are under the “Watcom” Classification. That means they are not portable across compiler. Granted QNX6 should have been more friendly to QNX4 programmers ;-)

The help and description given by the migration tool is informative enough, I think.

To replace kbdhit use tcischars( stdin ), check the doc on tcischars…

As for getch, you need to use read(stdin, …) but turn echo off by using tcgetattr() and tcsetattr().

Alternatively you could rework your application to use io_notify to get rid of that nasty polling for key press…

Hai mario,
Actually my english was not good, sorry for typoerror, I’ve still problem to set struct termios variable.
What should I do to turn echo off? Is this code valid?

struct termios termios_p;
tcgetattr( STDIN_FILENO, &termios_p );
termios_p.c_lflag =ECHOK|ECHOK;
tcsetattr( STDIN_FILENO, TCSADRAIN, &termios_p );

termios_p.c_lflag =ECHOK|ECHOK;

ECHOK | ECHOK does the same thing as ECHOK ( or maybe it’s another type)

As documented on the termios page, ECHO is the flag that control the echo ;-) Since you need to turn if off you must set that big to zero

termios_p.c_lflag &= (~ECHO);

I did what you said, my program did not behave like getch(). Could you plz show me what wrong?

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>

int main( void )
{

int n;
char c; 

struct termios termios_p;
tcgetattr( STDIN_FILENO, &termios_p );
termios_p.c_lflag &=(~ECHO);
tcsetattr( STDIN_FILENO, NULL, &termios_p );
struct sigevent event;
read(STDIN_FILENO,&c,1);
printf(" c : %c\n",c);

return EXIT_SUCCESS;
}

You forget to read the documentation on tcsetattr in which you would have find out that you need to set the second argument (i’ll let you figure out what value it should be set).

You would have probably figure it out have you check the return value of each functions and check for errors. tcsetattr() return -1 and set errno to EINVAL which in the docs says “The argument action is invalid, or one of the members of termios_p is invalid”. Can’t get any better then that.

You will also notice that read will not return unless you press return, I’ll give you a tip ICANON.

I highly suggest you throughly read the tcgetattr, tcsetattr and terrmio documentation, it’s all in there. Doc on tcsetattr even has a nice code sample!

ok, Thanks a lot.