I am trying to teach myself AI using neural networks. Long story short, I wanted to create a simple graphic that would display what is happening in my program using ncurses. The tutorial that I am using is found here.
I was under the impression that D was compatible with C and I could theoretically call C functions relatively easily.
I find that not to be the case. I am a relatively novice programmer, so even the simplistic explanations are a little above my head. I found this here.
D is designed to fit comfortably with a C compiler for the target system. D makes up for not having its own VM by relying on the target environment's C runtime library. It would be senseless to attempt to port to D or write D wrappers for the vast array of C APIs available. How much easier it is to just call them directly.
This is done by matching the C compiler's data types, layouts, and function call/return sequences.
That sounds wonderful. A little bit over my head. I tested and got a simple C program working:
#include <curses.h>
int main(void) {
int ch;
initscr();
noecho();
cbreak();
printw("Hit Ctrl+C to exit ...\n\n");
for (;;) {
ch = getch();
printw("Value of char: %d (%02x)\n", ch, ch);
}
endwin();
return 0;
}
shamelessly copied and pasted from another question on SO. At least I did my homework.
I tried basically the same thing from a simple D program. I got this error:
Error: module curses is in file 'curses.d' which cannot be read
I am absolutely positive that I am trying something really stupid.
Is there an easy way to use ncurses in a D program?
I'm running on zero sleep and caffeine, so please be gentle! Even a link to a website would be greatly appreciated!
I probably didn't include everything that I should have, so AMA.
And feel free to insult my intelligence.
Ok, I feel I have been spamming a little, but I hope that all of the info will be useful in the future.
I found a project name ycurses. I discovered the problem with TLS is specific to D2. I changed the files to work with D2. dmd, gdc, it all works. I finally have my ncurses using D! It just took a long weekend of marathon coding and researching.
Since the code I found is old and appears to be abandoned, I am now hosting it on github
Even though the code states it will work with Tango, IT WILL NOT. I'll probably fix that some time this week.
The code has a nice little tutorial included, as well as instruction on how to link. Your welcome. I feel very accomplished all of a sudden.