willett a écrit:
I'm trying to use ncurses and seem to be missing something dumb. I only want to use ncurses, not the CRT unit. My program is:
program testnc(input,output); begin writeln('begin test ncurses, before call to initscr');
initscr; writeln('after initscr'); endwin;
writeln('after endwin'); end.
When I compile the program, using:
gpc testnc.pas -lncurses -o testnc
I get compilation errors:
testnc.pas: In main program: testnc.pas:10: error: undeclared identifier `initscr' (first use in this routine) testnc.pas:12: error: undeclared identifier `endwin' (first use in this routine)
I tried uses GPC; (no change) and uses ncurses; (error: module/unit interface `ncurses' could not be imported)
What am I missing?
You need to write a Pascal import unit for ncurses, which translates the C syntax declarations in ncurses.h to pascal equivalents. Something like file ncurses.pas contains: -------------------------------------------------- unit ncurses; interface procedure initscr; external name 'initscr'; procedure endwin; external name 'endwin'; implementation {$L ncurses} {<- tell to load libncurses.a} end. -------------------------------------------------- if in ncurses.h they are declared as void initscr (void); void endwin (void); (in fact the declarations are more complex than that, and you have to find the Pascal equivalent) and then add in your main program --------------------------------------- program testnc(input,output); uses ncurses; begin ... ---------------------------------------- and compile with gpc --automake testnc.pas -o testnc (you need to add -lncurses only if you do not have written the {$L ncurses} line as above) For a very simple exercise you may include only the declarations you need in your main program, but for any serious work writing the unit with all declarations is the good choice, quite time consuming however ... Maurice -- Maurice Lombardi Laboratoire de Spectrometrie Physique, Universite Joseph Fourier de Grenoble, BP87 38402 Saint Martin d'Heres Cedex FRANCE Tel: 33 (0)4 76 51 47 51 Fax: 33 (0)4 76 63 54 95 mailto:Maurice.Lombardi@ujf-grenoble.fr