3
我有這些的(有點過高)編號:如何在Ruby FFI模塊中打包C常量?
extern TCODLIB_API const TCOD_color_t TCOD_red;
extern TCODLIB_API const TCOD_color_t TCOD_flame;
extern TCODLIB_API const TCOD_color_t TCOD_orange;
extern TCODLIB_API const TCOD_color_t TCOD_amber;
extern TCODLIB_API const TCOD_color_t TCOD_yellow;
extern TCODLIB_API const TCOD_color_t TCOD_lime;
我怎樣才能在價值觀上的Ruby端得好嗎?這感覺就像應該有一個attach_const相當於attach_function,如下使用:
module TCOD
extend FFI::Library
ffi_lib File.join(APP_ROOT, "libtcod-1.5.1/libtcod.so")
attach_function :color_RGB, 'TCOD_color_RGB', [:uchar, :uchar, :uchar], Color.val
end
我不希望有重新定義一切從lightest_sepia到desaturated_chartreuse如果可能的話...
給代碼示例,請。 –
@BorisStitnicky:完成。 – Ashe
遺憾的是,#define常量也沒有解決方案,但是這有助於:D –