authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-31 20:18:47-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-31 20:18:47-05:00
log3a11757d575342be0623dd5ec50f3a8aa10a3098
tree081c437ec1a0f17f8ce2548c17f0554de130a50e
parenta795e4ce32d0f0806a0cef7ca6bbc45533b77c61

add docs recommending to only have 1 cImport


1 files changed, 11 insertions(+), 0 deletions(-)

doc/langref.html.in+11
......@@ -3887,6 +3887,17 @@ comptime {
38873887 <code>@cInclude</code>, <code>@cDefine</code>, and <code>@cUndef</code> work
38883888 within this expression, appending to a temporary buffer which is then parsed as C code.
38893889 </p>
3890 <p>
3891 Usually you should only have one <code>@cImport</code> in your entire application, because it saves the compiler
3892 from invoking clang multiple times, and prevents inline functions from being duplicated.
3893 </p>
3894 <p>
3895 Reasons for having multiple <code>@cImport</code> expressions would be:
3896 </p>
3897 <ul>
3898 <li>To avoid a symbol collision, for example if foo.h and bar.h both <code>#define CONNECTION_COUNT</code></li>
3899 <li>To analyze the C code with different preprocessor defines</li>
3900 </ul>
38903901 {#see_also|Import from C Header File|@cInclude|@cDefine|@cUndef#}
38913902 {#header_close#}
38923903 {#header_open|@cInclude#}