如何判断 C 结构体是否有 Perl XS 中的成员?
是否有 ExtUtils::*
或 Module::Build
(或其他)类似于 Ruby 的 mkmf.have_struct_member
?
我想做类似的事情(以 hints/ 文件的方式):
....
if struct_has_member("msghdr", "msg_accrights") {
$self->{CCFLAGS} = join(' ', $self->{CCFLAGS}, "-DTRY_ACCRIGHTS_NOT_CMSG");
}
...
Config.pm
不会跟踪我正在查找的具体信息,并且ExtUtils::FindFunctions
在这里似乎不太合适......
Is there an ExtUtils::*
or Module::Build
(or other) analog to Ruby's mkmf.have_struct_member
?
I'd like to do something like (in the manner of a hints/ file):
....
if struct_has_member("msghdr", "msg_accrights") {
$self->{CCFLAGS} = join(' ', $self->{CCFLAGS}, "-DTRY_ACCRIGHTS_NOT_CMSG");
}
...
Config.pm
doesn't track the specific information I'm looking for, and ExtUtils::FindFunctions
didn't seem quite appropriate here...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这没有内置到 MakeMaker 或 Module::Build 中。 CPAN 上可能有一个东西可以做到这一点,但通常的方法是使用 ExtUtils::CBuilder 编译一个小测试程序并查看它是否运行。
可能想在临时文件中执行此操作并在其后进行清理,等等......
I know this is not built into either MakeMaker or Module::Build. There might be a thing on CPAN to do it, but the usual way is to use ExtUtils::CBuilder to compile up a little test program and see if it runs.
Probably want to do that in a temp file and clean up after it, etc...
我围绕 ExtUtils::CBuilder 编写了一个包装器,用于执行“此 C 代码是否可以编译?”在
Build.PL
或Makefile.PL
脚本中键入测试,称为 ExtUtils::CChecker。例如,您可以通过以下方式轻松测试上述内容:
I wrote a wrapper around
ExtUtils::CBuilder
for doing "does this C code compile?" type tests inBuild.PL
orMakefile.PL
scripts, called ExtUtils::CChecker.For example, you can easily test the above by: