gpt4 book ai didi

inline - SWIG : What is the different between "%inline %{ %}" and "%{ %}"?

转载 作者:行者123 更新时间:2023-12-04 14:00:51 39 4
gpt4 key购买 nike

我从文档中了解到的是 %{ %} 之间的内容。被插入到包装器中,%inline %{ %} 呢? ?

是一样的吗?如果不是,有什么区别?

也许我们可以找到很多%inline %{ %}的出现。但仅出现一次 %{ %} ?
十分感谢!

最佳答案

您可以多次出现这两种类型的 block 。 %{ ... }%只需在 SWIG 生成的文件中逐字插入 block 中的内容。它用于编译生成的文件,即您通常将任何包含和定义的内容放在那里,以便编译生成的文件。

OTOH,来自文档:

The %inline directive inserts all of the code that follows verbatim into the header portion of an interface file. The code is then parsed by both the SWIG preprocessor and parser.



所以 %inline %{ ... %}而是做了两件事:它将声明放在生成的包装器文件中,并导致 SWIG 生成包装器代码,以便可以从目标语言(Python、Lua 等)调用 block 中的函数等。 %{ ... }% 的情况并非如此。 : 此类 block 中的代码不会被包装,只是在生成的包装文件中逐字转储。

不要害怕打开 *_wrap.cpp SWIG 生成:将一些易于搜索的代码放入这两种类型的 block 中,并查看它们在包装文件中的最终位置,以及生成了哪些附加代码。

关于inline - SWIG : What is the different between "%inline %{ %}" and "%{ %}"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22119794/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com