如何找到 LC_XXX 区域设置整数常量的值,以便我可以将它们与 cffi 一起使用
我有这段代码:
(define-foreign-library libc
(:unix "libc.so.6"))
(use-foreign-library libc)
(defcfun "setlocale" :pointer (category :int) (locale :pointer))
并且我想做:
(with-foreign-string (locale "en_US.UTF-8")
(setlocale XXXX locale))
如何找到各种 LC_xxx 常量的整数值,以便我可以将它们传递给上面的调用?有更好的方法来实现这一目标吗?
I have this code:
(define-foreign-library libc
(:unix "libc.so.6"))
(use-foreign-library libc)
(defcfun "setlocale" :pointer (category :int) (locale :pointer))
and I want to do:
(with-foreign-string (locale "en_US.UTF-8")
(setlocale XXXX locale))
How can I find the integer values of the various LC_xxx constants so that I can pass them to the call above? Is there a better way of achieving this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在 Lisp 代码中重新声明常量。事实上,CFFI 可以为您做到这一点 。
You should re-declare the constants in your Lisp code. In fact, CFFI can do this for you.
我在 locale.h 中看到了这一点:
并且 bits/locale.h 包含:
您可以编译一个打印它们的 C 程序。
这就是格罗勒所做的。
I see this in my locale.h:
and bits/locale.h contains:
You could just compile a C program that prints them.
This is what the groveller does.