After installing Fsharp and Mono in Ubuntu server 14.04, I am trying to play around with NCurses. I let myself get inspired by several C# projects. And I got stuck on the following issue.
The printw function in /usr/include/ncurses.h is defined as follows:
extern NCURSES_EXPORT(int) printw (const char *,...)
The goal is that I can call this with:
printw("Hello world")
So how can I create an extern binding for this in fsharp? Note that it is the "..." which gives me the problems..
I already tried some stuff which did not work:
[<DllImport ("libncurses.so.5")>]
extern int printw(string s, [<ParamArray>] obj[] args)
It compiles, but a test results in:
bindings.printw("Hello world!")
----------------^^^^^^^^^^^^^^
/home/12345/fcurses/stdin(11,17): error FS0001: This expression was expected to have type
string * obj []
but here has type
string
According to section Parameter Arrays, only methods can have parameter arrays. And if I split the extern into a static extern with an accompaning method (inspired by the answer of this post), then extern is still used as a value, rather than a method, so no parameter array here as well.
Any ideas?