Page 1 of 1

importing variadic functions? (ncurses module)

Posted: Fri Aug 07, 2015 9:26 pm
by 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?
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:
(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.