importing variadic functions? (ncurses module)

Started by TedWalther, August 07, 2015, 02:26:03 PM

Previous topic - Next topic

TedWalther

I wanted to make a text mode app with newlisp.  I start to make an ncurses module so I can use ncurses.  Right away I find this function has a variable number of arguments.  What is the right way to import and use these?


Quote
       int printw(const char *fmt, ...);

       int wprintw(WINDOW *win, const char *fmt, ...);

       int mvprintw(int y, int x, const char *fmt, ...);

       int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...);

       int vwprintw(WINDOW *win, const char *fmt, va_list varglist);

       int vw_printw(WINDOW *win, const char *fmt, va_list varglist);


My first guess failed:


Quote
(import LIB_NCURSES "printw" "int" "void*")

(printw "abc %d %d %d" 1 2 3)

=> ERR: mismatch in number of arguments


How to do variadic functions using libffi?  Is it possible?  If this is a feature to be added, could we have "..." to specify variadic function?



And yes, it did work with the old cdecl style of import.  Then I lose the benefit of type checking. Oh well.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.