Random behavior using a wrapped C library
simendsjo
simendsjo at gmail.com
Tue Feb 28 07:49:58 PST 2012
I'm getting some unexpected results (crashes or random behavior) when
using a wrapped C struct in a library. I have no idea why this is
happening as everything else (including other wrapped structs) seems to
work just fine.
Could it be some alignment issues..?
extern(C):
//typedef unsigned char uint8;
alias ubyte uint8;
//typedef struct {
// uint8 r,g,b;
//} TCOD_color_t;
struct TCOD_color_t {
uint8 r,g,b;
};
//typedef void * TCOD_console_t;
alias void* TCOD_console_t;
//TCODLIB_API void TCOD_console_set_default_background(TCOD_console_t
con,TCOD_color_t col);
void TCOD_console_set_default_background(TCOD_console_t con,TCOD_color_t
col);
Whenever I use I call this function using TCOD_color_t(255,255,255) it
seems to set a random other value.
Also, when calling get_default_background (not shown here), I get random
results back.
I know the library works fine from C, so it has to be somewhere in my
wrapper.
Does anyone spot any obvious flaws in my wrapping above? Or has any other
hints on what might have gone wrong?
I've only tested this on linux64.
Thanks.
More information about the Digitalmars-d-learn
mailing list