importing variadic functions? (ncurses module)

Q&A's, tips, howto's

importing variadic functions? (ncurses module)

Postby TedWalther » Fri Aug 07, 2015 9:26 pm

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.
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.
TedWalther
 
Posts: 605
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests

cron