I've been trying to link a d program to a c library (ncurses in this case) on ubuntu 9.10 with dmd v2.036. Converting curses.c to a .d header seemed to go okay when I try to link the files together I get this:

dmd -c main.d
dmd -c curses.d
dmd main.o curses.o -L/usr/lib/libncurses.a
/usr/bin/ld: stdscr: TLS definition in curses.o section .tbss mismatches non-TLS reference in /usr/lib/libncurses.a(lib_initscr.o)
/usr/lib/libncurses.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

I eventually figured out that TLS is thread local storage. The -vtls looked helpful so I gave it a try:

dmd -c -vtls curses.d
curses.d(12): acs_map is thread local
curses.d(412): curscr is thread local
curses.d(413): newscr is thread local
curses.d(414): stdscr is thread local
curses.d(415): ttytype is thread local
curses.d(416): COLORS is thread local
curses.d(417): COLOR_PAIRS is thread local
curses.d(418): COLS is thread local
curses.d(419): ESCDELAY is thread local
curses.d(420): LINES is thread local
curses.d(421): TABSIZE

Here are what those lines look like in the file:

 WINDOW * curscr;
 WINDOW * newscr;
 WINDOW * stdscr;
 char ttytype[];
 int COLORS;
 int COLOR_PAIRS;
 int COLS;
 int ESCDELAY;
 int LINES;
 int TABSIZE;

It appears the header contains a smattering of variables dmd is assuming I want stored with thread local storage. Is there any way to tell dmd to just share them between threads? Everything is already wrapped with extern(C). Am I missing something?

Thanks,
Gareth

Reply via email to