willett wrote:
GPC Pascal programmers:
I have gotten a complete ncurses interface working for GNU Pascal. I have tested it on MaxOSX (using unix prompt), although more testing is needed. This is the UNIX terminal ncurses, no graphics.
The interface file (ncurses.pas), one-page documentation (ncurses.txt) and a few test files (*.pas) are attached as a gzip tar file (16k). Any testing or suggestions are welcome.
Sorry, but I see a number of type problems here (typical for direct C interfaces):
: - many int32 apparently should be ShortInt (int16), not fully investigated
C interfaces in GPC should always use the types provided for C compatibility. As ncurses doesn't use fixed-size types, int32 is probably not right here.
E.g., ncurses.h on my system contains:
typedef unsigned long chtype;
This would be translated to `MedCard' (see manual). On some systems, this is in fact 32 bits, but on others it's 64 bit, so it would break there.
However, I see that on some targets ncurses uses `unsigned int' for chtype (see its configure script) which would be `CCardinal', which further complicates the issue.
Direct linking to a C interface in a portable way is tricky sometimes. A safe way is writing C wrappers (some more overhead) or a fully automatic header translator (quite hard), otherwise you'll have to figure out a way to deal with it. (For specific cases such as this, you could check the installed ncurses.h and adjust according to it.)
: IntBool = MedBool; { was int in c (signed 32 bit integer), used only as a boolean }
BTW, if it's `int' in C, it should be `CBoolean'. `MedBool' corresponds to `[unsigned] long'.
Such problems are hard to detect tested on just one system as many wrong types happen to match anyway.
: tacs_map = ARRAY [char] OF chtype; { 128-byte, re-settable array, initially char->chtype }
In Pascal, this is no 128 byte array. Char has a range of 256 values (currently), and chtype is at least 32 bits. So the array has 256 elements and at least 1024 bytes.
BTW (unrelated), I'd suggest to rename the package to `gpc-ncurses-...' or `ncurses-gpc-...', to avoid confusion with an ncurses library package.
Frank