-
Notifications
You must be signed in to change notification settings - Fork 97
/
index.html
96 lines (76 loc) · 59.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="zh-cn"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>C 接口 · Julia中文文档</title><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-28835595-9', 'auto');
ga('send', 'pageview', {'page': location.pathname + location.search + location.hash});
</script><link rel="canonical" href="https://juliacn.github.io/JuliaZH.jl/latest/base/c/"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-dark.css" data-theme-name="documenter-dark"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../../assets/themeswap.js"></script><link href="../../assets/julia-manual.css" rel="stylesheet" type="text/css"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../../"><img src="../../assets/logo.png" alt="Julia中文文档 logo"/></a><div class="docs-package-name"><span class="docs-autofit">Julia中文文档</span></div><form class="docs-search" action="../../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../../">主页</a></li><li><span class="tocitem">手册</span><ul><li><a class="tocitem" href="../../manual/getting-started/">入门</a></li><li><a class="tocitem" href="../../manual/variables/">变量</a></li><li><a class="tocitem" href="../../manual/integers-and-floating-point-numbers/">整数和浮点数</a></li><li><a class="tocitem" href="../../manual/mathematical-operations/">数学运算和初等函数</a></li><li><a class="tocitem" href="../../manual/complex-and-rational-numbers/">复数和有理数</a></li><li><a class="tocitem" href="../../manual/strings/">字符串</a></li><li><a class="tocitem" href="../../manual/functions/">函数</a></li><li><a class="tocitem" href="../../manual/control-flow/">流程控制</a></li><li><a class="tocitem" href="../../manual/variables-and-scoping/">变量作用域</a></li><li><a class="tocitem" href="../../manual/types/">类型</a></li><li><a class="tocitem" href="../../manual/methods/">方法</a></li><li><a class="tocitem" href="../../manual/constructors/">构造函数</a></li><li><a class="tocitem" href="../../manual/conversion-and-promotion/">类型转换和类型提升</a></li><li><a class="tocitem" href="../../manual/interfaces/">接口</a></li><li><a class="tocitem" href="../../manual/modules/">模块</a></li><li><a class="tocitem" href="../../manual/documentation/">文档</a></li><li><a class="tocitem" href="../../manual/metaprogramming/">元编程</a></li><li><a class="tocitem" href="../../manual/arrays/">多维数组</a></li><li><a class="tocitem" href="../../manual/missing/">缺失值</a></li><li><a class="tocitem" href="../../manual/networking-and-streams/">网络和流</a></li><li><a class="tocitem" href="../../manual/parallel-computing/">并行计算</a></li><li><a class="tocitem" href="../../manual/asynchronous-programming/">异步编程</a></li><li><a class="tocitem" href="../../manual/multi-threading/">多线程</a></li><li><a class="tocitem" href="../../manual/distributed-computing/">多进程和分布式计算</a></li><li><a class="tocitem" href="../../manual/running-external-programs/">运行外部程序</a></li><li><a class="tocitem" href="../../manual/calling-c-and-fortran-code/">调用 C 和 Fortran 代码</a></li><li><a class="tocitem" href="../../manual/handling-operating-system-variation/">处理操作系统差异</a></li><li><a class="tocitem" href="../../manual/environment-variables/">环境变量</a></li><li><a class="tocitem" href="../../manual/embedding/">嵌入 Julia</a></li><li><a class="tocitem" href="../../manual/code-loading/">代码加载</a></li><li><a class="tocitem" href="../../manual/profile/">性能分析</a></li><li><a class="tocitem" href="../../manual/stacktraces/">栈跟踪</a></li><li><a class="tocitem" href="../../manual/performance-tips/">性能建议</a></li><li><a class="tocitem" href="../../manual/workflow-tips/">工作流程建议</a></li><li><a class="tocitem" href="../../manual/style-guide/">代码风格指南</a></li><li><a class="tocitem" href="../../manual/faq/">常见问题</a></li><li><a class="tocitem" href="../../manual/noteworthy-differences/">与其他语言的显著差异</a></li><li><a class="tocitem" href="../../manual/unicode-input/">Unicode 输入表</a></li><li><a class="tocitem" href="../../manual/command-line-options/">命令行选项</a></li></ul></li><li><span class="tocitem">Base</span><ul><li><a class="tocitem" href="../base/">基本功能</a></li><li><a class="tocitem" href="../collections/">集合和数据结构</a></li><li><a class="tocitem" href="../math/">数学相关</a></li><li><a class="tocitem" href="../numbers/">Numbers</a></li><li><a class="tocitem" href="../strings/">字符串</a></li><li><a class="tocitem" href="../arrays/">数组</a></li><li><a class="tocitem" href="../parallel/">Tasks</a></li><li><a class="tocitem" href="../multi-threading/">Multi-Threading</a></li><li><a class="tocitem" href="../constants/">常量</a></li><li><a class="tocitem" href="../file/">文件系统</a></li><li><a class="tocitem" href="../io-network/">I/O 与网络</a></li><li><a class="tocitem" href="../punctuation/">运算符与记号</a></li><li><a class="tocitem" href="../sort/">排序及相关函数</a></li><li><a class="tocitem" href="../iterators/">迭代相关</a></li><li class="is-active"><a class="tocitem" href>C 接口</a><ul class="internal"><li class="toplevel"><a class="tocitem" href="#LLVM-接口"><span>LLVM 接口</span></a></li></ul></li><li><a class="tocitem" href="../libc/">C 标准库</a></li><li><a class="tocitem" href="../stacktraces/">堆栈跟踪</a></li><li><a class="tocitem" href="../simd-types/">SIMD 支持</a></li></ul></li><li><span class="tocitem">Standard Library</span><ul><li><a class="tocitem" href="../../stdlib/Artifacts/">Artifacts</a></li><li><a class="tocitem" href="../../stdlib/Base64/">Base64</a></li><li><a class="tocitem" href="../../stdlib/CRC32c/">CRC32c</a></li><li><a class="tocitem" href="../../stdlib/Dates/">日期</a></li><li><a class="tocitem" href="../../stdlib/DelimitedFiles/">分隔符文件</a></li><li><a class="tocitem" href="../../stdlib/Distributed/">Distributed Computing</a></li><li><a class="tocitem" href="../../stdlib/FileWatching/">文件相关事件</a></li><li><a class="tocitem" href="../../stdlib/Future/">Future</a></li><li><a class="tocitem" href="../../stdlib/InteractiveUtils/">Interactive Utilities</a></li><li><a class="tocitem" href="../../stdlib/LazyArtifacts/">Lazy Artifacts</a></li><li><a class="tocitem" href="../../stdlib/LibGit2/">LibGit2</a></li><li><a class="tocitem" href="../../stdlib/Libdl/">动态链接器</a></li><li><a class="tocitem" href="../../stdlib/LinearAlgebra/">Linear Algebra</a></li><li><a class="tocitem" href="../../stdlib/Logging/">日志记录</a></li><li><a class="tocitem" href="../../stdlib/Markdown/">Markdown</a></li><li><a class="tocitem" href="../../stdlib/Mmap/">内存映射 I/O</a></li><li><a class="tocitem" href="../../stdlib/Printf/">Printf</a></li><li><a class="tocitem" href="../../stdlib/Profile/">性能分析</a></li><li><a class="tocitem" href="../../stdlib/REPL/">Julia REPL</a></li><li><a class="tocitem" href="../../stdlib/Random/">随机数</a></li><li><a class="tocitem" href="../../stdlib/SHA/">SHA</a></li><li><a class="tocitem" href="../../stdlib/Serialization/">序列化</a></li><li><a class="tocitem" href="../../stdlib/SharedArrays/">共享数组</a></li><li><a class="tocitem" href="../../stdlib/Sockets/">套接字</a></li><li><a class="tocitem" href="../../stdlib/SparseArrays/">稀疏数组</a></li><li><a class="tocitem" href="../../stdlib/Statistics/">统计</a></li><li><a class="tocitem" href="../../stdlib/TOML/">TOML</a></li><li><a class="tocitem" href="../../stdlib/Test/">单元测试</a></li><li><a class="tocitem" href="../../stdlib/UUIDs/">UUIDs</a></li><li><a class="tocitem" href="../../stdlib/Unicode/">Unicode</a></li></ul></li><li><span class="tocitem">Developer Documentation</span><ul><li><a class="tocitem" href="../../devdocs/reflection/">反射 与 自我检查</a></li><li><input class="collapse-toggle" id="menuitem-5-2" type="checkbox"/><label class="tocitem" for="menuitem-5-2"><span class="docs-label">Documentation of Julia's Internals</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../../devdocs/init/">Julia 运行时的初始化</a></li><li><a class="tocitem" href="../../devdocs/ast/">Julia 的 AST</a></li><li><a class="tocitem" href="../../devdocs/types/">More about types</a></li><li><a class="tocitem" href="../../devdocs/object/">Memory layout of Julia Objects</a></li><li><a class="tocitem" href="../../devdocs/eval/">Julia 代码的 eval</a></li><li><a class="tocitem" href="../../devdocs/callconv/">Calling Conventions</a></li><li><a class="tocitem" href="../../devdocs/compiler/">本机代码生成过程的高级概述</a></li><li><a class="tocitem" href="../../devdocs/functions/">Julia 函数</a></li><li><a class="tocitem" href="../../devdocs/cartesian/">笛卡尔</a></li><li><a class="tocitem" href="../../devdocs/meta/">Talking to the compiler (the <code>:meta</code> mechanism)</a></li><li><a class="tocitem" href="../../devdocs/subarrays/">子数组</a></li><li><a class="tocitem" href="../../devdocs/isbitsunionarrays/">isbits Union Optimizations</a></li><li><a class="tocitem" href="../../devdocs/sysimg/">System Image Building</a></li><li><a class="tocitem" href="../../devdocs/llvm/">Working with LLVM</a></li><li><a class="tocitem" href="../../devdocs/stdio/">printf() and stdio in the Julia runtime</a></li><li><a class="tocitem" href="../../devdocs/boundscheck/">边界检查</a></li><li><a class="tocitem" href="../../devdocs/locks/">Proper maintenance and care of multi-threading locks</a></li><li><a class="tocitem" href="../../devdocs/offset-arrays/">Arrays with custom indices</a></li><li><a class="tocitem" href="../../devdocs/require/">Module loading</a></li><li><a class="tocitem" href="../../devdocs/inference/">类型推导</a></li><li><a class="tocitem" href="../../devdocs/ssair/">Julia SSA-form IR</a></li><li><a class="tocitem" href="../../devdocs/gc-sa/">Static analyzer annotations for GC correctness in C code</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-5-3" type="checkbox"/><label class="tocitem" for="menuitem-5-3"><span class="docs-label">Developing/debugging Julia's C code</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../../devdocs/backtraces/">报告和分析崩溃(段错误)</a></li><li><a class="tocitem" href="../../devdocs/debuggingtips/">gdb 调试提示</a></li><li><a class="tocitem" href="../../devdocs/valgrind/">在Julia中使用Valgrind</a></li><li><a class="tocitem" href="../../devdocs/sanitizers/">Sanitizer support</a></li></ul></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Base</a></li><li class="is-active"><a href>C 接口</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>C 接口</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://www.transifex.com/juliacn/base-zh_cn/translate/#zh_CN/cmd" title=" 完善 Transifex 上的翻译"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch"> 完善 Transifex 上的翻译</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="设置"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="C-接口"><a class="docs-heading-anchor" href="#C-接口">C 接口</a><a id="C-接口-1"></a><a class="docs-heading-anchor-permalink" href="#C-接口" title="Permalink"></a></h1><article class="docstring"><header><a class="docstring-binding" id="Base.@ccall" href="#Base.@ccall"><code>Base.@ccall</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@ccall library.function_name(argvalue1::argtype1, ...)::returntype
@ccall function_name(argvalue1::argtype1, ...)::returntype
@ccall $function_pointer(argvalue1::argtype1, ...)::returntype</code></pre><p>Call a function in a C-exported shared library, specified by <code>library.function_name</code>, where <code>library</code> is a string constant or literal. The library may be omitted, in which case the <code>function_name</code> is resolved in the current process. Alternatively, <code>@ccall</code> may also be used to call a function pointer <code>$function_pointer</code>, such as one returned by <code>dlsym</code>.</p><p>Each <code>argvalue</code> to <code>@ccall</code> is converted to the corresponding <code>argtype</code>, by automatic insertion of calls to <code>unsafe_convert(argtype, cconvert(argtype, argvalue))</code>. (See also the documentation for <a href="#Base.unsafe_convert"><code>unsafe_convert</code></a> and <a href="#Base.cconvert"><code>cconvert</code></a> for further details.) In most cases, this simply results in a call to <code>convert(argtype, argvalue)</code>.</p><p><strong>Examples</strong></p><pre><code class="language-none">@ccall strlen(s::Cstring)::Csize_t</code></pre><p>This calls the C standard library function:</p><pre><code class="language-none">size_t strlen(char *)</code></pre><p>with a Julia variable named <code>s</code>. See also <code>ccall</code>.</p><p>Varargs are supported with the following convention:</p><pre><code class="language-none">@ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint</code></pre><p>The semicolon is used to separate required arguments (of which there must be at least one) from variadic arguments.</p><p>Example using an external library:</p><pre><code class="language-none"># C signature of g_uri_escape_string:
# char *g_uri_escape_string(const char *unescaped, const char *reserved_chars_allowed, gboolean allow_utf8);
const glib = "libglib-2.0"
@ccall glib.g_uri_escape_string(my_uri::Cstring, ":/"::Cstring, true::Cint)::Cstring</code></pre><p>The string literal could also be used directly before the function name, if desired <code>"libglib-2.0".g_uri_escape_string(...</code></p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L685-L732">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="ccall" href="#ccall"><code>ccall</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">ccall((function_name, library), returntype, (argtype1, ...), argvalue1, ...)
ccall(function_name, returntype, (argtype1, ...), argvalue1, ...)
ccall(function_pointer, returntype, (argtype1, ...), argvalue1, ...)</code></pre><p>Call a function in a C-exported shared library, specified by the tuple <code>(function_name, library)</code>, where each component is either a string or symbol. Instead of specifying a library, one can also use a <code>function_name</code> symbol or string, which is resolved in the current process. Alternatively, <code>ccall</code> may also be used to call a function pointer <code>function_pointer</code>, such as one returned by <code>dlsym</code>.</p><p>Note that the argument type tuple must be a literal tuple, and not a tuple-valued variable or expression.</p><p>Each <code>argvalue</code> to the <code>ccall</code> will be converted to the corresponding <code>argtype</code>, by automatic insertion of calls to <code>unsafe_convert(argtype, cconvert(argtype, argvalue))</code>. (See also the documentation for <a href="#Base.unsafe_convert"><code>unsafe_convert</code></a> and <a href="#Base.cconvert"><code>cconvert</code></a> for further details.) In most cases, this simply results in a call to <code>convert(argtype, argvalue)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1064-L1082">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Intrinsics.cglobal" href="#Core.Intrinsics.cglobal"><code>Core.Intrinsics.cglobal</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">cglobal((symbol, library) [, type=Cvoid])</code></pre><p>Obtain a pointer to a global variable in a C-exported shared library, specified exactly as in <a href="#ccall"><code>ccall</code></a>. Returns a <code>Ptr{Type}</code>, defaulting to <code>Ptr{Cvoid}</code> if no <code>Type</code> argument is supplied. The values can be read or written by <a href="#Base.unsafe_load"><code>unsafe_load</code></a> or <a href="#Base.unsafe_store!"><code>unsafe_store!</code></a>, respectively.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L7-L16">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@cfunction" href="#Base.@cfunction"><code>Base.@cfunction</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@cfunction(callable, ReturnType, (ArgumentTypes...,)) -> Ptr{Cvoid}
@cfunction($callable, ReturnType, (ArgumentTypes...,)) -> CFunction</code></pre><p>Generate a C-callable function pointer from the Julia function <code>callable</code> for the given type signature. To pass the return value to a <code>ccall</code>, use the argument type <code>Ptr{Cvoid}</code> in the signature.</p><p>Note that the argument type tuple must be a literal tuple, and not a tuple-valued variable or expression (although it can include a splat expression). And that these arguments will be evaluated in global scope during compile-time (not deferred until runtime). Adding a '$' in front of the function argument changes this to instead create a runtime closure over the local variable <code>callable</code> (this is not supported on all architectures).</p><p>See <a href="../../manual/calling-c-and-fortran-code/#Calling-C-and-Fortran-Code">manual section on ccall and cfunction usage</a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> function foo(x::Int, y::Int)
return x + y
end
julia> @cfunction(foo, Int, (Int, Int))
Ptr{Cvoid} @0x000000001b82fcd0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L38-L63">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.CFunction" href="#Base.CFunction"><code>Base.CFunction</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">CFunction struct</code></pre><p>Garbage-collection handle for the return value from <code>@cfunction</code> when the first argument is annotated with '$'. Like all <code>cfunction</code> handles, it should be passed to <code>ccall</code> as a <code>Ptr{Cvoid}</code>, and will be converted automatically at the call site to the appropriate type.</p><p>See <a href="#Base.@cfunction"><code>@cfunction</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L19-L28">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_convert" href="#Base.unsafe_convert"><code>Base.unsafe_convert</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">unsafe_convert(T, x)</code></pre><p>Convert <code>x</code> to a C argument of type <code>T</code> where the input <code>x</code> must be the return value of <code>cconvert(T, ...)</code>.</p><p>In cases where <a href="../base/#Base.convert"><code>convert</code></a> would need to take a Julia object and turn it into a <code>Ptr</code>, this function should be used to define and perform that conversion.</p><p>Be careful to ensure that a Julia reference to <code>x</code> exists as long as the result of this function will be used. Accordingly, the argument <code>x</code> to this function should never be an expression, only a variable name or field reference. For example, <code>x=a.b.c</code> is acceptable, but <code>x=[a,b,c]</code> is not.</p><p>The <code>unsafe</code> prefix on this function indicates that using the result of this function after the <code>x</code> argument to this function is no longer accessible to the program may cause undefined behavior, including program corruption or segfaults, at any later time.</p><p>See also <a href="#Base.cconvert"><code>cconvert</code></a></p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L34-L54">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.cconvert" href="#Base.cconvert"><code>Base.cconvert</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">cconvert(T,x)</code></pre><p>Convert <code>x</code> to a value to be passed to C code as type <code>T</code>, typically by calling <code>convert(T, x)</code>.</p><p>In cases where <code>x</code> cannot be safely converted to <code>T</code>, unlike <a href="../base/#Base.convert"><code>convert</code></a>, <code>cconvert</code> may return an object of a type different from <code>T</code>, which however is suitable for <a href="#Base.unsafe_convert"><code>unsafe_convert</code></a> to handle. The result of this function should be kept valid (for the GC) until the result of <a href="#Base.unsafe_convert"><code>unsafe_convert</code></a> is not needed anymore. This can be used to allocate memory that will be accessed by the <code>ccall</code>. If multiple objects need to be allocated, a tuple of the objects can be used as return value.</p><p>Neither <code>convert</code> nor <code>cconvert</code> should take a Julia object and turn it into a <code>Ptr</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L396-L409">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_load" href="#Base.unsafe_load"><code>Base.unsafe_load</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">unsafe_load(p::Ptr{T}, i::Integer=1)</code></pre><p>Load a value of type <code>T</code> from the address of the <code>i</code>th element (1-indexed) starting at <code>p</code>. This is equivalent to the C expression <code>p[i-1]</code>.</p><p>The <code>unsafe</code> prefix on this function indicates that no validation is performed on the pointer <code>p</code> to ensure that it is valid. Incorrect usage may segfault your program or return garbage answers, in the same manner as C.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L95-L104">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_store!" href="#Base.unsafe_store!"><code>Base.unsafe_store!</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">unsafe_store!(p::Ptr{T}, x, i::Integer=1)</code></pre><p>Store a value of type <code>T</code> to the address of the <code>i</code>th element (1-indexed) starting at <code>p</code>. This is equivalent to the C expression <code>p[i-1] = x</code>.</p><p>The <code>unsafe</code> prefix on this function indicates that no validation is performed on the pointer <code>p</code> to ensure that it is valid. Incorrect usage may corrupt or segfault your program, in the same manner as C.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L107-L116">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_copyto!-Union{Tuple{T}, Tuple{Ptr{T}, Ptr{T}, Any}} where T" href="#Base.unsafe_copyto!-Union{Tuple{T}, Tuple{Ptr{T}, Ptr{T}, Any}} where T"><code>Base.unsafe_copyto!</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">unsafe_copyto!(dest::Ptr{T}, src::Ptr{T}, N)</code></pre><p>Copy <code>N</code> elements from a source pointer to a destination, with no checking. The size of an element is determined by the type of the pointers.</p><p>The <code>unsafe</code> prefix on this function indicates that no validation is performed on the pointers <code>dest</code> and <code>src</code> to ensure that they are valid. Incorrect usage may corrupt or segfault your program, in the same manner as C.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/array.jl#L228-L237">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_copyto!-Union{Tuple{T}, Tuple{Array{T}, Any, Array{T}, Any, Any}} where T" href="#Base.unsafe_copyto!-Union{Tuple{T}, Tuple{Array{T}, Any, Array{T}, Any, Any}} where T"><code>Base.unsafe_copyto!</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">unsafe_copyto!(dest::Array, do, src::Array, so, N)</code></pre><p>Copy <code>N</code> elements from a source array to a destination, starting at offset <code>so</code> in the source and <code>do</code> in the destination (1-indexed).</p><p>The <code>unsafe</code> prefix on this function indicates that no validation is performed to ensure that N is inbounds on either array. Incorrect usage may corrupt or segfault your program, in the same manner as C.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/array.jl#L270-L279">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.copyto!" href="#Base.copyto!"><code>Base.copyto!</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">copyto!(dest, do, src, so, N)</code></pre><p>Copy <code>N</code> elements from collection <code>src</code> starting at offset <code>so</code>, to array <code>dest</code> starting at offset <code>do</code>. Return <code>dest</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/array.jl#L310-L315">source</a></section><section><div><pre><code class="language-none">copyto!(dest::AbstractArray, src) -> dest</code></pre><p>Copy all elements from collection <code>src</code> to array <code>dest</code>, whose length must be greater than or equal to the length <code>n</code> of <code>src</code>. The first <code>n</code> elements of <code>dest</code> are overwritten, the other elements are left untouched.</p><p>See also <a href="../arrays/#Base.copy!"><code>copy!</code></a>, <a href="../base/#Base.copy"><code>copy</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> x = [1., 0., 3., 0., 5.];
julia> y = zeros(7);
julia> copyto!(y, x);
julia> y
7-element Vector{Float64}:
1.0
0.0
3.0
0.0
5.0
0.0
0.0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/abstractarray.jl#L983-L1010">source</a></section><section><div><pre><code class="language-julia">copyto!(dest, Rdest::CartesianIndices, src, Rsrc::CartesianIndices) -> dest</code></pre><p>Copy the block of <code>src</code> in the range of <code>Rsrc</code> to the block of <code>dest</code> in the range of <code>Rdest</code>. The sizes of the two regions must match.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> A = zeros(5, 5);
julia> B = [1 2; 3 4];
julia> Ainds = CartesianIndices((2:3, 2:3));
julia> Binds = CartesianIndices(B);
julia> copyto!(A, Ainds, B, Binds)
5×5 Matrix{Float64}:
0.0 0.0 0.0 0.0 0.0
0.0 1.0 2.0 0.0 0.0
0.0 3.0 4.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/multidimensional.jl#L1133-L1157">source</a></section><section><div><pre><code class="language-none">copyto!(dest::AbstractMatrix, src::UniformScaling)</code></pre><p>Copies a <a href="../../stdlib/LinearAlgebra/#LinearAlgebra.UniformScaling"><code>UniformScaling</code></a> onto a matrix.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.1</header><div class="admonition-body"><p>In Julia 1.0 this method only supported a square destination matrix. Julia 1.1. added support for a rectangular matrix.</p></div></div></div></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.pointer" href="#Base.pointer"><code>Base.pointer</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">pointer(array [, index])</code></pre><p>Get the native address of an array or string, optionally at a given location <code>index</code>.</p><p>This function is "unsafe". Be careful to ensure that a Julia reference to <code>array</code> exists as long as this pointer will be used. The <a href="../base/#Base.GC.@preserve"><code>GC.@preserve</code></a> macro should be used to protect the <code>array</code> argument from garbage collection within a given block of code.</p><p>Calling <a href="#Core.Ref"><code>Ref(array[, index])</code></a> is generally preferable to this function as it guarantees validity.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L172-L183">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_wrap-Union{Tuple{N}, Tuple{T}, Tuple{Union{Type{Array}, Type{Array{T}}, Type{Array{T, N}}}, Ptr{T}, Tuple{Vararg{Int64, N}}}} where {T, N}" href="#Base.unsafe_wrap-Union{Tuple{N}, Tuple{T}, Tuple{Union{Type{Array}, Type{Array{T}}, Type{Array{T, N}}}, Ptr{T}, Tuple{Vararg{Int64, N}}}} where {T, N}"><code>Base.unsafe_wrap</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">unsafe_wrap(Array, pointer::Ptr{T}, dims; own = false)</code></pre><p>Wrap a Julia <code>Array</code> object around the data at the address given by <code>pointer</code>, without making a copy. The pointer element type <code>T</code> determines the array element type. <code>dims</code> is either an integer (for a 1d array) or a tuple of the array dimensions. <code>own</code> optionally specifies whether Julia should take ownership of the memory, calling <code>free</code> on the pointer when the array is no longer referenced.</p><p>This function is labeled "unsafe" because it will crash if <code>pointer</code> is not a valid memory address to data of the requested length.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L70-L81">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.pointer_from_objref" href="#Base.pointer_from_objref"><code>Base.pointer_from_objref</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">pointer_from_objref(x)</code></pre><p>Get the memory address of a Julia object as a <code>Ptr</code>. The existence of the resulting <code>Ptr</code> will not protect the object from garbage collection, so you must ensure that the object remains referenced for the whole time that the <code>Ptr</code> will be used.</p><p>This function may not be called on immutable objects, since they do not have stable memory addresses.</p><p>See also <a href="#Base.unsafe_pointer_to_objref"><code>unsafe_pointer_to_objref</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L132-L143">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.unsafe_pointer_to_objref" href="#Base.unsafe_pointer_to_objref"><code>Base.unsafe_pointer_to_objref</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">unsafe_pointer_to_objref(p::Ptr)</code></pre><p>Convert a <code>Ptr</code> to an object reference. Assumes the pointer refers to a valid heap-allocated Julia object. If this is not the case, undefined behavior results, hence this function is considered "unsafe" and should be used with care.</p><p>See also <a href="#Base.pointer_from_objref"><code>pointer_from_objref</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L121-L129">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.disable_sigint" href="#Base.disable_sigint"><code>Base.disable_sigint</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">disable_sigint(f::Function)</code></pre><p>Disable Ctrl-C handler during execution of a function on the current task, for calling external code that may call julia code that is not interrupt safe. Intended to be called using <code>do</code> block syntax as follows:</p><pre><code class="language-none">disable_sigint() do
# interrupt-unsafe code
...
end</code></pre><p>This is not needed on worker threads (<code>Threads.threadid() != 1</code>) since the <code>InterruptException</code> will only be delivered to the master thread. External functions that do not call julia code or julia runtime automatically disable sigint during their execution.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L454-L470">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.reenable_sigint" href="#Base.reenable_sigint"><code>Base.reenable_sigint</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">reenable_sigint(f::Function)</code></pre><p>Re-enable Ctrl-C handler during execution of a function. Temporarily reverses the effect of <a href="#Base.disable_sigint"><code>disable_sigint</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L479-L484">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.exit_on_sigint" href="#Base.exit_on_sigint"><code>Base.exit_on_sigint</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">exit_on_sigint(on::Bool)</code></pre><p>Set <code>exit_on_sigint</code> flag of the julia runtime. If <code>false</code>, Ctrl-C (SIGINT) is capturable as <a href="../base/#Core.InterruptException"><code>InterruptException</code></a> in <code>try</code> block. This is the default behavior in REPL, any code run via <code>-e</code> and <code>-E</code> and in Julia script run with <code>-i</code> option.</p><p>If <code>true</code>, <code>InterruptException</code> is not thrown by Ctrl-C. Running code upon such event requires <a href="../base/#Base.atexit"><code>atexit</code></a>. This is the default behavior in Julia script run without <code>-i</code> option.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>Function <code>exit_on_sigint</code> requires at least Julia 1.5.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L493-L507">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.systemerror" href="#Base.systemerror"><code>Base.systemerror</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">systemerror(sysfunc[, errno::Cint=Libc.errno()])
systemerror(sysfunc, iftrue::Bool)</code></pre><p>Raises a <code>SystemError</code> for <code>errno</code> with the descriptive string <code>sysfunc</code> if <code>iftrue</code> is <code>true</code></p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/error.jl#L169-L174">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.windowserror" href="#Base.windowserror"><code>Base.windowserror</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">windowserror(sysfunc[, code::UInt32=Libc.GetLastError()])
windowserror(sysfunc, iftrue::Bool)</code></pre><p>Like <a href="#Base.systemerror"><code>systemerror</code></a>, but for Windows API functions that use <a href="../libc/#Base.Libc.GetLastError"><code>GetLastError</code></a> to return an error code instead of setting <a href="../libc/#Base.Libc.errno"><code>errno</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/error.jl#L183-L189">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Ptr" href="#Core.Ptr"><code>Core.Ptr</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Ptr{T}</code></pre><p>A memory address referring to data of type <code>T</code>. However, there is no guarantee that the memory is actually valid, or that it actually represents data of the specified type.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/pointer.jl#L3-L8">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Ref" href="#Core.Ref"><code>Core.Ref</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Ref{T}</code></pre><p>An object that safely references data of type <code>T</code>. This type is guaranteed to point to valid, Julia-allocated memory of the correct type. The underlying data is protected from freeing by the garbage collector as long as the <code>Ref</code> itself is referenced.</p><p>In Julia, <code>Ref</code> objects are dereferenced (loaded or stored) with <code>[]</code>.</p><p>Creation of a <code>Ref</code> to a value <code>x</code> of type <code>T</code> is usually written <code>Ref(x)</code>. Additionally, for creating interior pointers to containers (such as Array or Ptr), it can be written <code>Ref(a, i)</code> for creating a reference to the <code>i</code>-th element of <code>a</code>.</p><p><code>Ref{T}()</code> creates a reference to a value of type <code>T</code> without initialization. For a bitstype <code>T</code>, the value will be whatever currently resides in the memory allocated. For a non-bitstype <code>T</code>, the reference will be undefined and attempting to dereference it will result in an error, "UndefRefError: access to undefined reference".</p><p>To check if a <code>Ref</code> is an undefined reference, use <a href="#Base.isassigned-Tuple{Base.RefValue}"><code>isassigned(ref::RefValue)</code></a>. For example, <code>isassigned(Ref{T}())</code> is <code>false</code> if <code>T</code> is not a bitstype. If <code>T</code> is a bitstype, <code>isassigned(Ref{T}())</code> will always be true.</p><p>When passed as a <code>ccall</code> argument (either as a <code>Ptr</code> or <code>Ref</code> type), a <code>Ref</code> object will be converted to a native pointer to the data it references. For most <code>T</code>, or when converted to a <code>Ptr{Cvoid}</code>, this is a pointer to the object data. When <code>T</code> is an <code>isbits</code> type, this value may be safely mutated, otherwise mutation is strictly undefined behavior.</p><p>As a special case, setting <code>T = Any</code> will instead cause the creation of a pointer to the reference itself when converted to a <code>Ptr{Any}</code> (a <code>jl_value_t const* const*</code> if T is immutable, else a <code>jl_value_t *const *</code>). When converted to a <code>Ptr{Cvoid}</code>, it will still return a pointer to the data region as for any other <code>T</code>.</p><p>A <code>C_NULL</code> instance of <code>Ptr</code> can be passed to a <code>ccall</code> <code>Ref</code> argument to initialize it.</p><p><strong>Use in broadcasting</strong></p><p><code>Ref</code> is sometimes used in broadcasting in order to treat the referenced values as a scalar.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Ref(5)
Base.RefValue{Int64}(5)
julia> isa.(Ref([1,2,3]), [Array, Dict, Int]) # Treat reference values as scalar during broadcasting
3-element BitVector:
1
0
0
julia> Ref{Function}() # Undefined reference to a non-bitstype, Function
Base.RefValue{Function}(#undef)
julia> try
Ref{Function}()[] # Dereferencing an undefined reference will result in an error
catch e
println(e)
end
UndefRefError()
julia> Ref{Int64}()[]; # A reference to a bitstype refers to an undetermined value if not given
julia> isassigned(Ref{Int64}()) # A reference to a bitstype is always assigned
true
julia> Ref{Int64}(0)[] == 0 # Explicitly give a value for a bitstype reference
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/refpointer.jl#L3-L72">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isassigned-Tuple{Base.RefValue}" href="#Base.isassigned-Tuple{Base.RefValue}"><code>Base.isassigned</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">isassigned(ref::RefValue) -> Bool</code></pre><p>Test whether the given <a href="#Core.Ref"><code>Ref</code></a> is associated with a value. This is always true for a <a href="#Core.Ref"><code>Ref</code></a> of a bitstype object. Return <code>false</code> if the reference is undefined.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> ref = Ref{Function}()
Base.RefValue{Function}(#undef)
julia> isassigned(ref)
false
julia> ref[] = (foobar(x) = x)
foobar (generic function with 1 method)
julia> isassigned(ref)
true
julia> isassigned(Ref{Int}())
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/refvalue.jl#L11-L35">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cchar" href="#Base.Cchar"><code>Base.Cchar</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cchar</code></pre><p>Equivalent to the native <code>char</code> c-type.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L86-L90">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cuchar" href="#Base.Cuchar"><code>Base.Cuchar</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cuchar</code></pre><p>Equivalent to the native <code>unsigned char</code> c-type (<a href="../numbers/#Core.UInt8"><code>UInt8</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L6-L10">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cshort" href="#Base.Cshort"><code>Base.Cshort</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cshort</code></pre><p>Equivalent to the native <code>signed short</code> c-type (<a href="../numbers/#Core.Int16"><code>Int16</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L14-L18">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cstring" href="#Base.Cstring"><code>Base.Cstring</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cstring</code></pre><p>A C-style string composed of the native character type <a href="#Base.Cchar"><code>Cchar</code></a>s. <code>Cstring</code>s are NUL-terminated. For C-style strings composed of the native wide character type, see <a href="#Base.Cwstring"><code>Cwstring</code></a>. For more information about string interopability with C, see the <a href="../../manual/calling-c-and-fortran-code/#man-bits-types">manual</a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L138-L147">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cushort" href="#Base.Cushort"><code>Base.Cushort</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cushort</code></pre><p>Equivalent to the native <code>unsigned short</code> c-type (<a href="../numbers/#Core.UInt16"><code>UInt16</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L22-L26">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cint" href="#Base.Cint"><code>Base.Cint</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cint</code></pre><p>Equivalent to the native <code>signed int</code> c-type (<a href="../numbers/#Core.Int32"><code>Int32</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L30-L34">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cuint" href="#Base.Cuint"><code>Base.Cuint</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cuint</code></pre><p>Equivalent to the native <code>unsigned int</code> c-type (<a href="../numbers/#Core.UInt32"><code>UInt32</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L38-L42">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Clong" href="#Base.Clong"><code>Base.Clong</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Clong</code></pre><p>Equivalent to the native <code>signed long</code> c-type.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L104-L108">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Culong" href="#Base.Culong"><code>Base.Culong</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Culong</code></pre><p>Equivalent to the native <code>unsigned long</code> c-type.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L111-L115">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Clonglong" href="#Base.Clonglong"><code>Base.Clonglong</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Clonglong</code></pre><p>Equivalent to the native <code>signed long long</code> c-type (<a href="../numbers/#Core.Int64"><code>Int64</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L86-L90">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Culonglong" href="#Base.Culonglong"><code>Base.Culonglong</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Culonglong</code></pre><p>Equivalent to the native <code>unsigned long long</code> c-type (<a href="../numbers/#Core.UInt64"><code>UInt64</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L94-L98">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cintmax_t" href="#Base.Cintmax_t"><code>Base.Cintmax_t</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cintmax_t</code></pre><p>Equivalent to the native <code>intmax_t</code> c-type (<a href="../numbers/#Core.Int64"><code>Int64</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L70-L74">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cuintmax_t" href="#Base.Cuintmax_t"><code>Base.Cuintmax_t</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cuintmax_t</code></pre><p>Equivalent to the native <code>uintmax_t</code> c-type (<a href="../numbers/#Core.UInt64"><code>UInt64</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L78-L82">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Csize_t" href="#Base.Csize_t"><code>Base.Csize_t</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Csize_t</code></pre><p>Equivalent to the native <code>size_t</code> c-type (<code>UInt</code>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L54-L58">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cssize_t" href="#Base.Cssize_t"><code>Base.Cssize_t</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cssize_t</code></pre><p>Equivalent to the native <code>ssize_t</code> c-type.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L62-L66">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cptrdiff_t" href="#Base.Cptrdiff_t"><code>Base.Cptrdiff_t</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cptrdiff_t</code></pre><p>Equivalent to the native <code>ptrdiff_t</code> c-type (<code>Int</code>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L46-L50">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cwchar_t" href="#Base.Cwchar_t"><code>Base.Cwchar_t</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cwchar_t</code></pre><p>Equivalent to the native <code>wchar_t</code> c-type (<a href="../numbers/#Core.Int32"><code>Int32</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L118-L122">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cwstring" href="#Base.Cwstring"><code>Base.Cwstring</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cwstring</code></pre><p>A C-style string composed of the native wide character type <a href="#Base.Cwchar_t"><code>Cwchar_t</code></a>s. <code>Cwstring</code>s are NUL-terminated. For C-style strings composed of the native character type, see <a href="#Base.Cstring"><code>Cstring</code></a>. For more information about string interopability with C, see the <a href="../../manual/calling-c-and-fortran-code/#man-bits-types">manual</a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/c.jl#L125-L135">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cfloat" href="#Base.Cfloat"><code>Base.Cfloat</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cfloat</code></pre><p>Equivalent to the native <code>float</code> c-type (<a href="../numbers/#Core.Float32"><code>Float32</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L102-L106">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Cdouble" href="#Base.Cdouble"><code>Base.Cdouble</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Cdouble</code></pre><p>Equivalent to the native <code>double</code> c-type (<a href="../numbers/#Core.Float64"><code>Float64</code></a>).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ctypes.jl#L110-L114">source</a></section></article><h1 id="LLVM-接口"><a class="docs-heading-anchor" href="#LLVM-接口">LLVM 接口</a><a id="LLVM-接口-1"></a><a class="docs-heading-anchor-permalink" href="#LLVM-接口" title="Permalink"></a></h1><article class="docstring"><header><a class="docstring-binding" id="Core.Intrinsics.llvmcall" href="#Core.Intrinsics.llvmcall"><code>Core.Intrinsics.llvmcall</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">llvmcall(fun_ir::String, returntype, Tuple{argtype1, ...}, argvalue1, ...)
llvmcall((mod_ir::String, entry_fn::String), returntype, Tuple{argtype1, ...}, argvalue1, ...)
llvmcall((mod_bc::Vector{UInt8}, entry_fn::String), returntype, Tuple{argtype1, ...}, argvalue1, ...)</code></pre><p>Call the LLVM code provided in the first argument. There are several ways to specify this first argument:</p><ul><li>as a literal string, representing function-level IR (similar to an LLVM <code>define</code> block), with arguments are available as consecutive unnamed SSA variables (%0, %1, etc.);</li><li>as a 2-element tuple, containing a string of module IR and a string representing the name of the entry-point function to call;</li><li>as a 2-element tuple, but with the module provided as an <code>Vector{UINt8}</code> with bitcode.</li></ul><p>Note that contrary to <code>ccall</code>, the argument types must be specified as a tuple type, and not a tuple of types. All types, as well as the LLVM code, should be specified as literals, and not as variables or expressions (it may be necessary to use <code>@eval</code> to generate these literals).</p><p>See <code>test/llvmcall.jl</code> for usage examples.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1085-L1105">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../iterators/">« 迭代相关</a><a class="docs-footer-nextpage" href="../libc/">C 标准库 »</a><div class="flexbox-break"></div><p class="footer-message">📢📢📢 JuliaCN 2022 冬季见面会 报告<a href="https://cn.julialang.org/meetup-website/2022/">征集</a></p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">设置</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">选择主题</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>本文档在<span class="colophon-date" title="2023 十月 21 周六 15:28">2023 十月 21 周六</span>由<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a>使用1.8.5版本的Julia生成。</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>