梦见莲藕是什么意思| 茉莉茶属于什么茶| 平均血小板体积偏低是什么意思| 苹果a1661是什么型号| 女性私处痒是什么原因引起的| 缺陷是什么意思| 缺钙应该吃什么| 嗜酸性肉芽肿是什么病| 1989属什么| 绿茶什么时候喝最好| 正切是什么| 爱情是什么颜色的| 肠化十是什么意思| 什么药清肺化痰好| tp代表什么| 纪元是什么意思| 黑头发有什么好处脑筋急转弯| 一个木一个寿念什么| 有什么有什么四字词语| 吃什么最补肾壮阳| 什么是相位| 什么是肝掌| 宝齐莱手表什么档次| 为什么拔罐肩膀最黑| 尿崩症吃什么药最有效| 纯磨玻璃结节是什么意思| 乳晕是什么意思| 叛逆期是什么意思| 橙子皮泡水喝有什么好处| 生目念什么| 糙皮病是什么病| 贝壳吃什么| 主动脉瓣退行性变是什么意思| 当归长什么样的图片| 康斯坦丁是什么意思| 柔式按摩是什么意思| 女生被插是什么感觉| 通五行属什么| 马太效应是什么意思| 小棉袄是什么意思| 海带与什么食物相克| 新生儿黄疸高是什么原因| 滑脉是什么意思| 前列腺穿刺是什么意思| 降真香是什么| 蜜饯是什么| 长时间手淫有什么危害| 六味地黄丸是治什么的| 尿道感染吃什么药好得快| noon什么意思| 更年期吃什么药调理| 为什么额头反复长痘痘| lot是什么意思| 舌苔黄腻吃什么中成药| 什么是腹式呼吸| 妊娠纹什么时候开始长| 乸是什么意思| 虎的本命佛是什么佛| 男人跑马是什么意思| 微针是什么| 中年人吃什么钙片补钙效果好| 傍大款是什么意思| 观音坐莲什么意思| 前列腺炎有些什么症状| 抑郁状态和抑郁症有什么区别| 梅毒检查挂什么科| 牙齿上有黑点是什么原因| 10月1日什么星座| 龙涎香什么味道| 什么字笔画最多| 中国的母亲河是什么河| 办理慢性病需要什么手续| 红豆和什么搭配最好| 口干舌燥吃什么药最好| 茶壶里煮饺子的歇后语是什么| 同病相怜什么意思| 人乳头瘤病毒阴性是什么意思| kelme是什么牌子| 官杀是什么| 肛门周围痒是什么原因| 塑料水杯什么材质好| 肩胛骨疼痛是什么原因| 陶弘景有什么之称| 脖子上有结节挂什么科| 双鱼座的上升星座是什么| 胸椎退行性变什么意思| 决断是什么意思| 吃什么可以增加黄体酮| 男孩学什么专业好| 1970年属狗是什么命| 国家电网是什么单位| 狗狗耳螨用什么药| 肛裂用什么药| 高考600多分能上什么大学| psh是什么意思| 一直放臭屁是什么原因| 虎父无犬子什么意思| 咳嗽是什么原因引起的| 水瓶座什么象| 早晨起床手肿胀是什么原因| 褶皱是什么意思| 总lge是什么意思| 爱被蚊子咬是什么原因| 杰作是什么意思| 皇太极叫什么名字| 不排大便是什么原因| 后背的骨头叫什么| 人肉搜索是什么意思| 1967属什么生肖| 什么是双重人格| 精子不液化吃什么药| 梦见小孩是什么意思| 口舌痣是什么意思| 梦见自己会开车了是什么意思| 得了肠息肉有什么症状| 舌尖疼是什么原因| 心态好是什么意思| 腱鞘炎吃什么药最好| 属猪的跟什么属相最配| 3.8号是什么星座| 好哒是什么意思| 发泡实验是检查什么的| 后壁是什么意思| 沙特是什么教派| 卡罗莱手表是什么档次| 尿道炎看什么科室好| 吃芒果有什么好处和坏处| 噬是什么意思| 背上有痣代表什么| 这是什么表情包| 毅力是什么意思| 胚芽米是什么米| 山麻雀吃什么| 奥利奥是什么意思| 画蛇添足告诉我们什么道理| 人武部是干什么的| 什么叫根管治疗| 心慌是什么症状| 朝花夕拾什么意思| 胃阴不足吃什么中成药| 扁桃体溃疡吃什么药| 血性是什么意思| few是什么意思| 金的部首是什么| 猫的五行属什么| 三八是什么意思| 时过境迁是什么意思| 为什么邓超对鹿晗很好| 百草霜是什么| 什么样的嘴巴| 不负众望什么意思| 晒后修复用什么比较好| 卦是什么意思| 冠状沟有白色分泌物是什么原因| 巨人观是什么意思| 唇炎应该挂什么科室| 子宫内膜粘连有什么症状| 牙齿出血是什么病表现出来的症状| 欧巴是什么意思| 三叉神经是什么病| 抗结剂是什么| 番茄和蕃茄有什么区别| 夫星是什么意思| 静待佳音什么意思| 为什么吃饱了就犯困| 脚上起水泡用什么药膏| 什么长什么短| 美国为什么不敢打伊朗| 1110是什么星座| 换肾是什么病| 美国为什么有两块土地| 哼哈二将是什么意思| 排卵期有什么| 焱加木念什么| 什么杯子喝水最健康| 湿疹用什么药膏最好| 玩微博的都是什么人| 梦见把头发剪短了是什么意思| 中蛊什么意思| 韵母是什么| 小青蛙吃什么| 在岸人民币和离岸人民币什么意思| 萘普生是什么药| 手指肿胀什么原因| 梅花手表属于什么档次| qn医学上是什么意思| 梦见橘子是什么意思| 得了肠息肉有什么症状| crab是什么意思| 火什么银花| 积液是什么东西| 花青素是什么颜色| 肾结石是什么原因导致的| 1972年出生属什么生肖| 卟是什么意思| 念旧的人属于什么性格| 回流什么意思| 阑尾炎吃什么食物好| 木耳菜不能和什么一起吃| lt是什么| 老人肚子胀是什么原因| 一年四季都盛开的花是什么花| 人体最大的免疫器官是什么| 梦见大蛇是什么意思| 小美女是什么意思| 二级警督是什么级别| 外阴瘙痒用什么| 风团是什么原因引起的| 什么是美尼尔氏综合症| 高压低压是什么意思| silk是什么意思| 咽炎是什么症状| 什么药治胃炎效果好| 非分之想什么意思| 产妇能吃什么水果| 倾情是什么意思| 血脂高吃什么食物| 醋泡葡萄干有什么功效和作用| 寄什么快递最便宜| 月经期间吃什么对身体好| 口腔疱疹吃什么药| 98年什么命| 梦见小兔子是什么意思| 9527什么意思| 四维是什么| 腹部胀气是什么原因| 喜悦之情溢于言表什么意思| 什么是像素| 千米的字母是什么| 屁的成分是什么气体| 包馄饨用猪肉什么部位| 经期有血块是什么原因| 舌苔有裂纹是什么原因| 诸多是什么意思| 如果是什么意思| 俄罗斯信奉的是什么教| 肺部结节灶是什么意思啊| p是什么意思啊| 琥珀酱是什么味| 翠色是什么颜色| 干咳吃什么食物好| 69是什么意思| 晕车喝什么饮料| 花哨是什么意思| 嘴巴里甜甜的是什么原因| 减肥平台期什么意思| 的近义词是什么| 六味地黄丸有什么副作用吗| 检查骨密度挂什么科| 脚筋膜炎什么办法恢复的最快| 手机cpu是什么| 感悟是什么意思| 为什么会得hpv| 查hcg挂什么科| 感光是什么意思| 草木皆兵的意思是什么| 龙舌兰是什么酒| 肋骨断了是什么感觉| 鸡炖什么好吃| 橄榄枝象征着什么| 艾绒是什么| 上海话册那是什么意思| 石英岩质玉是什么玉| 皮肤细菌感染用什么药| 百度Jump to content

山东冠县光大复合材料有限公司年产35万吨热...

From Wikipedia, the free encyclopedia
百度 不过北京青年报记者昨天调查发现,中国市场并没有受到美国的影响,在药店,念慈菴枇杷膏的零售价格为每瓶元,在网上药店零售价格为48元,且货源充足。

A foreign function interface (FFI) is a mechanism by which a program written in one programming language can call routines or make use of services written or compiled in another one. An FFI is often used in contexts where calls are made into a binary dynamic-link library.

Naming

[edit]

The term comes from the specification for Common Lisp, which explicitly refers to the programming language feature enabling for inter-language calls as such;[citation needed] the term is also often used officially by the interpreter and compiler documentation for Haskell,[1] Rust,[2] PHP,[3] Python, and LuaJIT (Lua)[4][5]:?35?.[6] Other languages use other terminology: Ada has language bindings, while Java has Java Native Interface (JNI), Java Native Access (JNA), or since Java 22, Foreign Function and Memory API. Foreign function interface has become generic terminology for mechanisms which provide such services.

Operation

[edit]

The primary function of a foreign function interface is to mate the semantics and calling conventions of one programming language (the host language, or the language which defines the FFI), with the semantics and conventions of another (the guest language). This process must also take into consideration the runtime environments and application binary interfaces of both. This can be done in several ways:

  • Requiring that guest-language functions which are to be host-language callable be specified or implemented in a particular way, often using a compatibility library of some sort.
  • Use of a tool to automatically wrap guest-language functions with appropriate glue code, which performs any necessary translation.
  • Use of a wrapper library
  • Restricting the set of host language abilities which can be used cross-language. For example, C++ functions called from C may not (in general) include reference parameters or throw exceptions.

FFIs may be complicated by the following considerations:

  • If one language supports garbage collection (GC) and the other does not; care must be taken that the non-GC language code does nothing to cause GC in the other to fail. In JNI, for example, C code which "holds on to" object references that it receives from Java must communicate this information successfully to the Java virtual machine or Java Runtime Environment (JRE), otherwise, Java may delete objects before C finishes with them. (The C code must also explicitly release its link to any such object once C has no further need of that object.)
  • Complicated or non-trivial objects or datatypes may be difficult to map from one environment to another.
  • It may not be possible for both languages to maintain references to the same instance of a mutable object, due to the mapping issue above.
  • One or both languages may be running on a virtual machine (VM); moreover, if both are, these are often different VMs.
  • Cross-language inheritance and other differences, such as between type systems or between object composition models, may be especially difficult.

UML ffi.svg

Examples of FFIs include:

  • Ada language bindings, allowing not only to call foreign functions but also to export its functions and methods to be called from non-Ada code.[7]
  • C++ has a trivial FFI with C, as the languages share a significant common subset. The primary effect of the extern "C" declaration in C++ is to disable C++ name mangling. With other languages, separate utils or middleware are used, examples include:
  • Clean provides a bidirectional FFI with all languages following C or the stdcall calling convention.[8][9]
  • Common Lisp
  • Compiled Native Interface (CNI), alternative to JNI used in the GNU compiler environment.
  • One of the bases of the Component Object Model is a common interface format, which natively uses the same types as Visual Basic for strings and arrays.
  • D does it the same way as C++ does, with extern "C" through extern (C++)
  • Dart includes dart:ffi[10] library to call native C code for mobile, command-line, and server applications
  • Dynamic programming languages, such as Python, Perl, Tcl, and Ruby, all provide easy access to native code written in C, C++, or any other language obeying C/C++ calling conventions.
  • Factor has FFIs for C, Fortran, Objective-C, and Windows COM; all of these enable importing and calling arbitrary shared libraries dynamically.
  • Fortran 2003 has a module ISO_C_BINDING which provides interoperable data types (both intrinsic types and POD structs), interoperable pointers, interoperable global data stores, and mechanisms for calling C from Fortran and for calling Fortran from C.[11] It has been improved in the Fortran 2018 standard.
  • Go can call C code directly via the "C" pseudo-package.[12]
  • Google Web Toolkit (GWT), in which Java is compiled to JavaScript, has an FFI named JSNI which allows Java source code to call arbitrary JavaScript functions, and for JavaScript to call back into Java.
  • Haskell
  • Java Native Interface (JNI), which provides an interface between Java and C/C++, the preferred systems languages on most systems where Java is deployed. Java Native Access (JNA) provides an interface with native libraries without having to write glue code. In Java 22, the Foreign Function and Memory API was added which is a modern replacement for JNI.
  • LuaJIT, a just-in-time implementation of Lua, has an FFI that allows "calling external C functions and using C data structures from pure Lua code".[4][5]:?35?
  • .NET have FFI through its LibraryImport attribute.
  • Nim has an FFI which enables it to use source from C, C++, and Objective-C. It can also interface with JavaScript.
  • JavaScript usually runs inside web browser runtimes that don't provide direct access to system libraries or commands to run, but there are few exceptions:
    • Node.js provides functions to open precompiled .node modules that in turn may provide access to non-builtin resources.
    • Deno, provides kind of FFI interface via dlopen(...) functions.[13]
    • Bun provides a built-in module, bun:ffi, to efficiently call native libraries directly from JavaScript.[14]
  • Julia has ccall keyword to call C (and other languages, e.g., Fortran);[15] while packages, providing similar no-boilerplate support, are available for some languages e.g., for Python[16] (to e.g. provide OO support and GC support), Java (and supports other JDK-languages, such as Scala) and R. Interactive use with C++ is also possible with Cxx.jl package.
  • PhoneGap (was named Apache Callback, but is now Apache Cordova) is a platform for building native mobile applications using HTML, CSS and JavaScript. Also, it has FFIs via JavaScript callback functions for access to methods and properties of mobile phone's native features including accelerometer, camera (also PhotoLibrary and SavedPhotoAlbum), compass, storage (SQL database and localStorage), notification, media and capture (playing and recording or audio and video), file, contacts (address book), events, device, and connection information.[1],[2].
  • PHP provides FFI to C.[17]
  • Pony supports integration with C via its FFI.[18]
  • Python provides the ctypes and cffi modules. For example, the ctypes module can load C functions from a shared library, or dynamic-link library (DLL) on-the-fly and translate simple data types automatically between Python and C semantics as follows:
    import ctypes
    libc = ctypes.CDLL("/lib/libc.so.6")  # Under Linux/Unix
    t = libc.time(None)                   # Equivalent C code: t = time(NULL)
    print(t)
    
  • P/Invoke, which provides an interface between the Microsoft Common Language Runtime and native code.
  • Racket has a native FFI based heavily on macros that enables importing arbitrary shared libraries dynamically.[19][20]
  • Raku can call Ruby, Python, Perl, Brainfuck, Lua, C, C++, Go, Scheme (Guile, Gambit), and Rust[21][22]
  • Ruby provides FFI either through the ffi gem, or through the standard library fiddle.
    require 'fiddle'
    
    libm = Fiddle.dlopen('/lib/libm.so.6')
    
    # Equivalent to: double floor(double x);
    floor = Fiddle::Function.new(
      libm.sym('floor'),     # ptr is a referenced function(, or symbol), of a Fiddle::Handle.
      [Fiddle::TYPE_DOUBLE], # args is an Array of arguments, passed to the ptr function.
      Fiddle::TYPE_DOUBLE    # ret_type is the return type of the function
    )
    
    # Equivalent to: floor(3.14159);
    floor.call(3.14159) #=> 3.0
    
  • Rust defines a foreign function interface to functions with various standard application binary interface (ABIs) in namespace std::ffi for calling C code.[23] There is also a library called CXX for interfacing with C++, as well as for Elixir, Rustler.
  • V (Vlang) can include and supports the use of C source code and libraries.[24]
  • Visual Basic has a declarative syntax that allows it to call non-Unicode C functions.
  • Wolfram Language provides a technology named Wolfram Symbolic Transfer Protocol (WSTP) which enables bidirectional calling of code between other languages with bindings for C++, Java, .NET. and other languages.
  • Zig provides FFI to C using the builtin cImport function.[25]

In addition, many FFIs can be generated automatically: for example, SWIG. However, in the case of an extension language a semantic inversion of the relationship of guest and host can occur, when a smaller body of extension language is the guest invoking services in the larger body of host language, such as writing a small plugin[26] for GIMP.[27]

Some FFIs are restricted to free standing functions, while others also allow calls of functions embedded in an object or class (often called method calls); some even permit migration of complex datatypes or objects across the language boundary.

In most cases, an FFI is defined by a higher-level language, so that it may employ services defined and implemented in a lower-level language, typically a system programming language like C or C++. This is typically done to either access operating system (OS) services in the language in which the OS API is defined, or for performance goals.

Many FFIs also provide the means for the called language to invoke services in the host language also.

The term foreign function interface is generally not used to describe multi-lingual runtimes such as the Microsoft Common Language Runtime, where a common substrate is provided which enables any CLR-compliant language to use services defined in any other. (However, in this case the CLR does include an FFI, P/Invoke, to call outside the runtime.) In addition, many distributed computing architectures such as the Java remote method invocation (RMI), RPC, CORBA, SOAP and D-Bus permit different services to be written in different languages; such architectures are generally not considered FFIs.

Special cases

[edit]

There are some special cases, in which the languages compile into the same bytecode VM, like Clojure and Java, as well as Elixir and Erlang. Since there is no interface, it is not an FFI, strictly speaking, while it offers the same functions to the user.

See also

[edit]

References

[edit]
  1. ^ "FFI Introduction". HaskellWiki. Retrieved 19 June 2015. Haskell's FFI is used to call functions from other languages (basically C at this point), and for C to call Haskell functions.
  2. ^ "std::ffi". Rust-lang.org. Retrieved 1 April 2021. This module provides utilities to handle data across non-Rust interfaces, like other programming languages and the underlying operating system. It is mainly of use for FFI (Foreign Function Interface) bindings and code that needs to exchange C-like strings with other languages.
  3. ^ "PHP FFI Manual". PHP Manual. Retrieved 31 August 2023. Defined C variables are made available as properties of the FFI instance.
  4. ^ a b Mike Pall. "FFI Library". Luajit.org. Retrieved 2025-08-05.
  5. ^ a b Heintz, Joachim; Hofmann, Alex; McCurdy, Iain (2013). Ways Ahead: Proceedings of the First International Csound Conference. Newcastle upon Tyne: Cambridge Scholars Publishing. ISBN 978-1-4438-5122-0. OCLC 855505215.
  6. ^ "CFFI documentation". Retrieved 19 June 2015. C Foreign Function Interface for Python. The goal is to provide a convenient and reliable way to call compiled C code from Python using interface declarations written in C.
  7. ^ "Interface to Other Languages". Adaic.org. Retrieved 2025-08-05.
  8. ^ "Foreign Export". Retrieved 2025-08-05.
  9. ^ "Calling C From Clean". Retrieved 2025-08-05.
  10. ^ "dart:ffi library". Retrieved 2025-08-05.
  11. ^ "'fortran-iso-c-binding' tag wiki". Stack Overflow.
  12. ^ "cgo". Go Programming Language. Retrieved 2025-08-05.
  13. ^ "Foreign Function Interface | Manual". Deno. Retrieved 2025-08-05.
  14. ^ "FFI API". Bun Docs.
  15. ^ "Calling C and Fortran Code". JuliaLang.org. Retrieved 2025-08-05.
  16. ^ PyCall.jl: Package to call Python functions from the Julia language, JuliaPy, 2025-08-05, retrieved 2025-08-05
  17. ^ "PHP: FFI - Manual". The PHP Group. Retrieved 13 June 2019.
  18. ^ "Pony C-FFI Overview". Retrieved 9 April 2025.
  19. ^ Eli Barzilay. "The Racket Foreign Interface". Docs.racket-lang.org. Retrieved 2025-08-05.
  20. ^ "TR600.pdf" (PDF). Archived from the original (PDF) on 2025-08-05. Retrieved 2025-08-05.
  21. ^ "Inline implementations". Retrieved 2025-08-05.
  22. ^ "Native Call". Retrieved 2025-08-05.
  23. ^ "Using extern Functions to Call External Code". Retrieved 2025-08-05.
  24. ^ "Including C code". Vlang. Retrieved 2025-08-05.
  25. ^ "Import from C Header File". Zig Software Foundation. Retrieved 2025-08-05.
  26. ^ "4. A sample script". Gimp.org. 2025-08-05. Retrieved 2025-08-05.
  27. ^ "Script-Fu and plug-ins for The GIMP". Gimp.org. Retrieved 2025-08-05.
[edit]


舌苔发黑是什么病的前兆 盗墓笔记讲了什么 幼儿园什么时候开学 舌头发麻看什么科 男人毛发旺盛说明什么
扁桃是什么水果 阴茎不硬吃什么 o型血rh阳性是什么意思 舅舅的孙子叫我什么 痛风吃什么药好得快
霸王硬上弓是什么意思 pop什么意思 血虚吃什么药 月经不规律吃什么药调理 王字旁的字跟什么有关
舌头起泡是什么原因引起的 eis是什么意思 七个月宝宝可以吃什么辅食 腋窝淋巴结肿大挂什么科 嘴唇肿了是什么原因
荨麻疹用什么药最好hcv8jop3ns1r.cn 哈工大全称是什么hcv8jop0ns4r.cn 为什么会长痣hcv7jop7ns4r.cn 什么是设计hcv9jop3ns3r.cn 三八是什么意思hcv9jop0ns6r.cn
35岁属什么的hcv7jop6ns0r.cn 食之无味什么意思hcv8jop3ns5r.cn 属鼠的和什么属相相克hcv8jop4ns1r.cn 什么是医院感染hcv9jop2ns0r.cn ibm是做什么的zsyouku.com
滑石是什么hcv9jop1ns3r.cn 改姓需要什么手续hcv8jop1ns5r.cn 犬瘟吃什么药管用dayuxmw.com 尼特族是什么意思hcv8jop8ns7r.cn 立春吃什么clwhiglsz.com
谭字五行属什么jasonfriends.com 什么是强直性脊柱炎bjhyzcsm.com 经常吐口水是什么原因zhongyiyatai.com 2月13号是什么星座hcv8jop1ns6r.cn 智商120是什么水平hcv9jop8ns0r.cn
百度