Skip to content

Commit

Permalink
add docs recommending to only have 1 cImport
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Feb 1, 2018
1 parent a795e4c commit 3a11757
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/langref.html.in
Expand Up @@ -3887,6 +3887,17 @@ comptime {
<code>@cInclude</code>, <code>@cDefine</code>, and <code>@cUndef</code> work
within this expression, appending to a temporary buffer which is then parsed as C code.
</p>
<p>
Usually you should only have one <code>@cImport</code> in your entire application, because it saves the compiler
from invoking clang multiple times, and prevents inline functions from being duplicated.
</p>
<p>
Reasons for having multiple <code>@cImport</code> expressions would be:
</p>
<ul>
<li>To avoid a symbol collision, for example if foo.h and bar.h both <code>#define CONNECTION_COUNT</code></li>
<li>To analyze the C code with different preprocessor defines</li>
</ul>
{#see_also|Import from C Header File|@cInclude|@cDefine|@cUndef#}
{#header_close#}
{#header_open|@cInclude#}
Expand Down

0 comments on commit 3a11757

Please sign in to comment.