Binding C to Crystal: preprocessor directives

£可爱£侵袭症+ 提交于 2019-12-25 11:49:29

问题


I'm working with the crt.cr Crystal shard, which binds ncurses. It's lacking some things I want, like mvhline(). So I'm adding the things I want.

One thing I want is is ncurses alternative character sheet, so I can make nice boxes.

As far as I can tell, this is pretty dang hard (but I'm not an expert in either Crystal or C). From what I can tell, the alternative character sheet characters are all unsigned chars, defined by the preprocessor.

Can someone explain how I can get access to the alternative character sheet characters?


回答1:


You cannot access things that are only in C header files (and things that are done through the preprocessor) in a shared library file, because they simply aren't put there.

Since Crystal only binds to a shared library file, there is no option other than manually (sometimes automatically) duplicating these as constants in Crystal code.



来源:https://stackoverflow.com/questions/43646456/binding-c-to-crystal-preprocessor-directives

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!