| ... | @@ -77,13 +77,7 @@ Hello, world!</code></pre> | ... | @@ -77,13 +77,7 @@ Hello, world!</code></pre> |
| 77 | pub fn main() -&gt; %void { | 77 | pub fn main() -&gt; %void { |
| 78 | warn("Hello, world!\n"); | 78 | warn("Hello, world!\n"); |
| 79 | }</code></pre> | 79 | }</code></pre> |
| 80 | <p>See also:</p> | 80 | {#see_also|Values|@import|Errors|Root Source File#} |
| 81 | <ul> | | |
| 82 | <li><a href="#values">Values</a></li> | | |
| 83 | <li><a href="#builtin-import">@import</a></li> | | |
| 84 | <li><a href="#errors">Errors</a></li> | | |
| 85 | <li><a href="#root-source-file">Root Source File</a></li> | | |
| 86 | </ul> | | |
| 87 | {#header_close#} | 81 | {#header_close#} |
| 88 | {#header_open|Source Encoding#} | 82 | {#header_open|Source Encoding#} |
| 89 | <p>Zig source code is encoded in UTF-8. An invalid UTF-8 byte sequence results in a compile error.</p> | 83 | <p>Zig source code is encoded in UTF-8. An invalid UTF-8 byte sequence results in a compile error.</p> |
| ... | @@ -391,13 +385,7 @@ value: 1234</code></pre> | ... | @@ -391,13 +385,7 @@ value: 1234</code></pre> |
| 391 | <td>an error code</td> | 385 | <td>an error code</td> |
| 392 | </tr> | 386 | </tr> |
| 393 | </table> | 387 | </table> |
| 394 | <p>See also:</p> | 388 | {#see_also|Integers|Floats|void|Errors#} |
| 395 | <ul> | | |
| 396 | <li><a href="#integers">Integers</a></li> | | |
| 397 | <li><a href="#floats">Floats</a></li> | | |
| 398 | <li><a href="#void">void</a></li> | | |
| 399 | <li><a href="#errors">Errors</a></li> | | |
| 400 | </ul> | | |
| 401 | {#header_close#} | 389 | {#header_close#} |
| 402 | {#header_open|Primitive Values#} | 390 | {#header_open|Primitive Values#} |
| 403 | <table> | 391 | <table> |
| ... | @@ -426,11 +414,7 @@ value: 1234</code></pre> | ... | @@ -426,11 +414,7 @@ value: 1234</code></pre> |
| 426 | <td>refers to the thing in immediate scope</td> | 414 | <td>refers to the thing in immediate scope</td> |
| 427 | </tr> | 415 | </tr> |
| 428 | </table> | 416 | </table> |
| 429 | <p>See also:</p> | 417 | {#see_also|Nullables|this#} |
| 430 | <ul> | | |
| 431 | <li><a href="#nullables">Nullables</a></li> | | |
| 432 | <li><a href="#this">this</a></li> | | |
| 433 | </ul> | | |
| 434 | {#header_close#} | 418 | {#header_close#} |
| 435 | {#header_open|String Literals#} | 419 | {#header_open|String Literals#} |
| 436 | <pre><code class="zig">const assert = @import("std").debug.assert; | 420 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| ... | @@ -452,11 +436,7 @@ test "string literals" { | ... | @@ -452,11 +436,7 @@ test "string literals" { |
| 452 | }</code></pre> | 436 | }</code></pre> |
| 453 | <pre><code class="sh">$ zig test string_literals.zig | 437 | <pre><code class="sh">$ zig test string_literals.zig |
| 454 | Test 1/1 string literals...OK</code></pre> | 438 | Test 1/1 string literals...OK</code></pre> |
| 455 | <p>See also:</p> | 439 | {#see_also|Arrays|Zig Test#} |
| 456 | <ul> | | |
| 457 | <li><a href="#arrays">Arrays</a></li> | | |
| 458 | <li><a href="#zig-test">Zig Test</a></li> | | |
| 459 | </ul> | | |
| 460 | {#header_open|Escape Sequences#} | 440 | {#header_open|Escape Sequences#} |
| 461 | <table> | 441 | <table> |
| 462 | <tr> | 442 | <tr> |
| ... | @@ -538,10 +518,7 @@ Test 1/1 string literals...OK</code></pre> | ... | @@ -538,10 +518,7 @@ Test 1/1 string literals...OK</code></pre> |
| 538 | In this example the variable <code>c_string_literal</code> has type <code>&amp;const char</code> and | 518 | In this example the variable <code>c_string_literal</code> has type <code>&amp;const char</code> and |
| 539 | has a terminating null byte. | 519 | has a terminating null byte. |
| 540 | </p> | 520 | </p> |
| 541 | <p>See also:</p> | 521 | {#see_also|@embedFile#} |
| 542 | <ul> | | |
| 543 | <li><a href="#builtin-embedFile">@embedFile</a></li> | | |
| 544 | </ul> | | |
| 545 | {#header_close#} | 522 | {#header_close#} |
| 546 | {#header_close#} | 523 | {#header_close#} |
| 547 | {#header_open|Assignment#} | 524 | {#header_open|Assignment#} |
| ... | @@ -627,12 +604,7 @@ const binary_int = 0b11110000;</code></pre> | ... | @@ -627,12 +604,7 @@ const binary_int = 0b11110000;</code></pre> |
| 627 | integer overflow. Also available are operations such as <code>+%</code> and | 604 | integer overflow. Also available are operations such as <code>+%</code> and |
| 628 | <code>-%</code> which are defined to have wrapping arithmetic on all targets. | 605 | <code>-%</code> which are defined to have wrapping arithmetic on all targets. |
| 629 | </p> | 606 | </p> |
| 630 | <p>See also:</p> | 607 | {#see_also|Integer Overflow|Division by Zero|Wrapping Operations#} |
| 631 | <ul> | | |
| 632 | <li><a href="#undef-integer-overflow">Integer Overflow</a></li> | | |
| 633 | <li><a href="#undef-division-by-zero">Division By Zero</a></li> | | |
| 634 | <li><a href="#undef-int-overflow-wrap">Wrapping Operations</a></li> | | |
| 635 | </ul> | | |
| 636 | {#header_close#} | 608 | {#header_close#} |
| 637 | {#header_close#} | 609 | {#header_close#} |
| 638 | {#header_open|Floats#} | 610 | {#header_open|Floats#} |
| ... | @@ -680,11 +652,7 @@ $ zig build-exe test.zig --object foo.o | ... | @@ -680,11 +652,7 @@ $ zig build-exe test.zig --object foo.o |
| 680 | $ ./test | 652 | $ ./test |
| 681 | optimized = 1.0e-2 | 653 | optimized = 1.0e-2 |
| 682 | strict = 9.765625e-3</code></pre> | 654 | strict = 9.765625e-3</code></pre> |
| 683 | <p>See also:</p> | 655 | {#see_also|@setFloatMode|Division by Zero#} |
| 684 | <ul> | | |
| 685 | <li><a href="#builtin-setFloatMode">@setFloatMode</a></li> | | |
| 686 | <li><a href="#undef-division-by-zero">Division By Zero</a></li> | | |
| 687 | </ul> | | |
| 688 | {#header_close#} | 656 | {#header_close#} |
| 689 | {#header_open|Operators#} | 657 | {#header_open|Operators#} |
| 690 | {#header_open|Table of Operators#} | 658 | {#header_open|Table of Operators#} |
| ... | @@ -1402,11 +1370,7 @@ Test 1/4 iterate over an array...OK | ... | @@ -1402,11 +1370,7 @@ Test 1/4 iterate over an array...OK |
| 1402 | Test 2/4 modify an array...OK | 1370 | Test 2/4 modify an array...OK |
| 1403 | Test 3/4 compile-time array initalization...OK | 1371 | Test 3/4 compile-time array initalization...OK |
| 1404 | Test 4/4 array initialization with function calls...OK</code></pre> | 1372 | Test 4/4 array initialization with function calls...OK</code></pre> |
| 1405 | <p>See also:</p> | 1373 | {#see_also|for|Slices#} |
| 1406 | <ul> | | |
| 1407 | <li><a href="#for">for</a></li> | | |
| 1408 | <li><a href="#slices">Slices</a></li> | | |
| 1409 | </ul> | | |
| 1410 | {#header_close#} | 1374 | {#header_close#} |
| 1411 | {#header_open|Pointers#} | 1375 | {#header_open|Pointers#} |
| 1412 | <pre><code class="zig">const assert = @import("std").debug.assert; | 1376 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| ... | @@ -1659,11 +1623,7 @@ Tests failed. Use the following command to reproduce the failure: | ... | @@ -1659,11 +1623,7 @@ Tests failed. Use the following command to reproduce the failure: |
| 1659 | <p>Instead, use <a href="#builtin-bitCast">@bitCast</a>: | 1623 | <p>Instead, use <a href="#builtin-bitCast">@bitCast</a>: |
| 1660 | <pre><code class="zig">@bitCast(u32, f32(12.34))</code></pre> | 1624 | <pre><code class="zig">@bitCast(u32, f32(12.34))</code></pre> |
| 1661 | <p>As an added benefit, the <code>@bitcast</code> version works at compile-time.</p> | 1625 | <p>As an added benefit, the <code>@bitcast</code> version works at compile-time.</p> |
| 1662 | <p>See also:</p> | 1626 | {#see_also|Slices|Memory#} |
| 1663 | <ul> | | |
| 1664 | <li><a href="#slices">Slices</a></li> | | |
| 1665 | <li><a href="#memory">Memory</a></li> | | |
| 1666 | </ul> | | |
| 1667 | {#header_close#} | 1627 | {#header_close#} |
| 1668 | {#header_close#} | 1628 | {#header_close#} |
| 1669 | {#header_open|Slices#} | 1629 | {#header_open|Slices#} |
| ... | @@ -1760,12 +1720,7 @@ test "slice widening" { | ... | @@ -1760,12 +1720,7 @@ test "slice widening" { |
| 1760 | Test 1/3 using slices for strings...OK | 1720 | Test 1/3 using slices for strings...OK |
| 1761 | Test 2/3 slice pointer...OK | 1721 | Test 2/3 slice pointer...OK |
| 1762 | Test 3/3 slice widening...OK</code></pre> | 1722 | Test 3/3 slice widening...OK</code></pre> |
| 1763 | <p>See also:</p> | 1723 | {#see_also|Pointers|for|Arrays#} |
| 1764 | <ul> | | |
| 1765 | <li><a href="#pointers">Pointers</a></li> | | |
| 1766 | <li><a href="#for">for</a></li> | | |
| 1767 | <li><a href="#arrays">Arrays</a></li> | | |
| 1768 | </ul> | | |
| 1769 | {#header_close#} | 1724 | {#header_close#} |
| 1770 | {#header_open|struct#} | 1725 | {#header_open|struct#} |
| 1771 | <pre><code class="zig">// Declare a struct. | 1726 | <pre><code class="zig">// Declare a struct. |
| ... | @@ -1907,11 +1862,7 @@ Test 1/4 dot product...OK | ... | @@ -1907,11 +1862,7 @@ Test 1/4 dot product...OK |
| 1907 | Test 2/4 struct namespaced variable...OK | 1862 | Test 2/4 struct namespaced variable...OK |
| 1908 | Test 3/4 field parent pointer...OK | 1863 | Test 3/4 field parent pointer...OK |
| 1909 | Test 4/4 linked list...OK</code></pre> | 1864 | Test 4/4 linked list...OK</code></pre> |
| 1910 | <p>See also:</p> | 1865 | {#see_also|comptime|@fieldParentPtr#} |
| 1911 | <ul> | | |
| 1912 | <li><a href="#comptime">comptime</a></li> | | |
| 1913 | <li><a href="#builtin-fieldParentPtr">@fieldParentPtr</a></li> | | |
| 1914 | </ul> | | |
| 1915 | {#header_close#} | 1866 | {#header_close#} |
| 1916 | {#header_open|enum#} | 1867 | {#header_open|enum#} |
| 1917 | <pre><code class="zig">const assert = @import("std").debug.assert; | 1868 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| ... | @@ -2024,12 +1975,7 @@ Test 5/8 @TagType...OK | ... | @@ -2024,12 +1975,7 @@ Test 5/8 @TagType...OK |
| 2024 | Test 6/8 @memberCount...OK | 1975 | Test 6/8 @memberCount...OK |
| 2025 | Test 7/8 @memberName...OK | 1976 | Test 7/8 @memberName...OK |
| 2026 | Test 8/8 @tagName...OK</code></pre> | 1977 | Test 8/8 @tagName...OK</code></pre> |
| 2027 | <p>See also:</p> | 1978 | {#see_also|@memberName|@memberCount|@tagName#} |
| 2028 | <ul> | | |
| 2029 | <li><a href="#builtin-memberName">@memberName</a></li> | | |
| 2030 | <li><a href="#builtin-memberCount">@memberCount</a></li> | | |
| 2031 | <li><a href="#builtin-tagName">@tagName</a></li> | | |
| 2032 | </ul> | | |
| 2033 | {#header_close#} | 1979 | {#header_close#} |
| 2034 | {#header_open|union#} | 1980 | {#header_open|union#} |
| 2035 | <pre><code class="zig">const assert = @import("std").debug.assert; | 1981 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| ... | @@ -2235,13 +2181,7 @@ test "switch inside function" { | ... | @@ -2235,13 +2181,7 @@ test "switch inside function" { |
| 2235 | Test 1/2 switch simple...OK | 2181 | Test 1/2 switch simple...OK |
| 2236 | Test 2/2 switch enum...OK | 2182 | Test 2/2 switch enum...OK |
| 2237 | Test 3/3 switch inside function...OK</code></pre> | 2183 | Test 3/3 switch inside function...OK</code></pre> |
| 2238 | <p>See also:</p> | 2184 | {#see_also|comptime|enum|@compileError|Compile Variables#} |
| 2239 | <ul> | | |
| 2240 | <li><a href="#comptime">comptime</a></li> | | |
| 2241 | <li><a href="#enum">enum</a></li> | | |
| 2242 | <li><a href="#builtin-compileError">@compileError</a></li> | | |
| 2243 | <li><a href="#compile-variables">Compile Variables</a></li> | | |
| 2244 | </ul> | | |
| 2245 | {#header_close#} | 2185 | {#header_close#} |
| 2246 | {#header_open|while#} | 2186 | {#header_open|while#} |
| 2247 | <pre><code class="zig">const assert = @import("std").debug.assert; | 2187 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| ... | @@ -2404,14 +2344,7 @@ Test 5/8 while loop continuation expression, more complicated...OK | ... | @@ -2404,14 +2344,7 @@ Test 5/8 while loop continuation expression, more complicated...OK |
| 2404 | Test 6/8 while else...OK | 2344 | Test 6/8 while else...OK |
| 2405 | Test 7/8 while null capture...OK | 2345 | Test 7/8 while null capture...OK |
| 2406 | Test 8/8 inline while loop...OK</code></pre> | 2346 | Test 8/8 inline while loop...OK</code></pre> |
| 2407 | <p>See also:</p> | 2347 | {#see_also|if|Nullables|Errors|comptime|unreachable#} |
| 2408 | <ul> | | |
| 2409 | <li><a href="#if">if</a></li> | | |
| 2410 | <li><a href="#nullables">Nullables</a></li> | | |
| 2411 | <li><a href="#errors">Errors</a></li> | | |
| 2412 | <li><a href="#comptime">comptime</a></li> | | |
| 2413 | <li><a href="#unreachable">unreachable</a></li> | | |
| 2414 | </ul> | | |
| 2415 | {#header_close#} | 2348 | {#header_close#} |
| 2416 | {#header_open|for#} | 2349 | {#header_open|for#} |
| 2417 | <pre><code class="zig">const assert = @import("std").debug.assert; | 2350 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| ... | @@ -2507,13 +2440,7 @@ Test 1/4 for basics...OK | ... | @@ -2507,13 +2440,7 @@ Test 1/4 for basics...OK |
| 2507 | Test 2/4 for reference...OK | 2440 | Test 2/4 for reference...OK |
| 2508 | Test 3/4 for else...OK | 2441 | Test 3/4 for else...OK |
| 2509 | Test 4/4 inline for loop...OK</code></pre> | 2442 | Test 4/4 inline for loop...OK</code></pre> |
| 2510 | <p>See also:</p> | 2443 | {#see_also|while|comptime|Arrays|Slices#} |
| 2511 | <ul> | | |
| 2512 | <li><a href="#while">while</a></li> | | |
| 2513 | <li><a href="#comptime">comptime</a></li> | | |
| 2514 | <li><a href="#arrays">Arrays</a></li> | | |
| 2515 | <li><a href="#slices">Slices</a></li> | | |
| 2516 | </ul> | | |
| 2517 | {#header_close#} | 2444 | {#header_close#} |
| 2518 | {#header_open|if#} | 2445 | {#header_open|if#} |
| 2519 | <pre><code class="zig">// If expressions have three uses, corresponding to the three types: | 2446 | <pre><code class="zig">// If expressions have three uses, corresponding to the three types: |
| ... | @@ -2628,29 +2555,9 @@ test "if error union" { | ... | @@ -2628,29 +2555,9 @@ test "if error union" { |
| 2628 | Test 1/3 if boolean...OK | 2555 | Test 1/3 if boolean...OK |
| 2629 | Test 2/3 if nullable...OK | 2556 | Test 2/3 if nullable...OK |
| 2630 | Test 3/3 if error union...OK</code></pre> | 2557 | Test 3/3 if error union...OK</code></pre> |
| 2631 | <p>See also:</p> | 2558 | {#see_also|Nullables|Errors#} |
| 2632 | <ul> | | |
| 2633 | <li><a href="#nullables">Nullables</a></li> | | |
| 2634 | <li><a href="#errors">Errors</a></li> | | |
| 2635 | </ul> | | |
| 2636 | {#header_close#} | 2559 | {#header_close#} |
| 2637 | {#header_open|goto#} | 2560 | {#header_open|defer#} |
| 2638 | <pre><code class="zig">const assert = @import("std").debug.assert; | | |
| 2639 | | | |
| 2640 | test "goto" { | | |
| 2641 | var value = false; | | |
| 2642 | goto label; | | |
| 2643 | value = true; | | |
| 2644 | | | |
| 2645 | label: | | |
| 2646 | assert(value == false); | | |
| 2647 | } | | |
| 2648 | </code></pre> | | |
| 2649 | <pre><code class="sh">$ zig test goto.zig | | |
| 2650 | Test 1/1 goto...OK | | |
| 2651 | </code></pre> | | |
| 2652 | <p>Note that there are <a href="https://github.com/zig-lang/zig/issues/346">plans to remove goto</a></p> | | |
| 2653 | {{deheader_open:fer}} | | |
| 2654 | <pre><code class="zig">const assert = @import("std").debug.assert; | 2561 | <pre><code class="zig">const assert = @import("std").debug.assert; |
| 2655 | const printf = @import("std").io.stdout.printf; | 2562 | const printf = @import("std").io.stdout.printf; |
| 2656 | | 2563 | |
| ... | @@ -2736,10 +2643,7 @@ encountered an error! | ... | @@ -2736,10 +2643,7 @@ encountered an error! |
| 2736 | end of function | 2643 | end of function |
| 2737 | OK | 2644 | OK |
| 2738 | </code></pre> | 2645 | </code></pre> |
| 2739 | <p>See also:</p> | 2646 | {#see_also|Errors#} |
| 2740 | <ul> | | |
| 2741 | <li><a href="#errors">Errors</a></li> | | |
| 2742 | </ul> | | |
| 2743 | {#header_close#} | 2647 | {#header_close#} |
| 2744 | {#header_open|unreachable#} | 2648 | {#header_open|unreachable#} |
| 2745 | <p> | 2649 | <p> |
| ... | @@ -2811,12 +2715,7 @@ comptime { | ... | @@ -2811,12 +2715,7 @@ comptime { |
| 2811 | test.zig:9:12: error: unreachable code | 2715 | test.zig:9:12: error: unreachable code |
| 2812 | assert(@typeOf(unreachable) == noreturn); | 2716 | assert(@typeOf(unreachable) == noreturn); |
| 2813 | ^</code></pre> | 2717 | ^</code></pre> |
| 2814 | <p>See also:</p> | 2718 | {#see_also|Zig Test|Build Mode|comptime#} |
| 2815 | <ul> | | |
| 2816 | <li><a href="#zig-test">Zig Test</a></li> | | |
| 2817 | <li><a href="#build-mode">Build Mode</a></li> | | |
| 2818 | <li><a href="#comptime">comptime</a></li> | | |
| 2819 | </ul> | | |
| 2820 | {#header_close#} | 2719 | {#header_close#} |
| 2821 | {#header_close#} | 2720 | {#header_close#} |
| 2822 | {#header_open|noreturn#} | 2721 | {#header_open|noreturn#} |
| ... | @@ -3142,12 +3041,7 @@ pub fn parseU64(buf: []const u8, radix: u8) -&gt; %u64 { | ... | @@ -3142,12 +3041,7 @@ pub fn parseU64(buf: []const u8, radix: u8) -&gt; %u64 { |
| 3142 | in other languages. | 3041 | in other languages. |
| 3143 | </li> | 3042 | </li> |
| 3144 | </ul> | 3043 | </ul> |
| 3145 | <p>See also:</p> | 3044 | {#see_also|defer|if|switch#} |
| 3146 | <ul> | | |
| 3147 | <li><a href="#defer">defer</a></li> | | |
| 3148 | <li><a href="#if">if</a></li> | | |
| 3149 | <li><a href="#switch">switch</a></li> | | |
| 3150 | </ul> | | |
| 3151 | {#header_close#} | 3045 | {#header_close#} |
| 3152 | {#header_open|Nullables#} | 3046 | {#header_open|Nullables#} |
| 3153 | <p> | 3047 | <p> |
| ... | @@ -3976,11 +3870,7 @@ comptime { | ... | @@ -3976,11 +3870,7 @@ comptime { |
| 3976 | The result is a target-specific compile time constant. It is guaranteed to be | 3870 | The result is a target-specific compile time constant. It is guaranteed to be |
| 3977 | less than or equal to <a href="#builtin-sizeOf">@sizeOf(T)</a>. | 3871 | less than or equal to <a href="#builtin-sizeOf">@sizeOf(T)</a>. |
| 3978 | </p> | 3872 | </p> |
| 3979 | <p>See also:</p> | 3873 | {#see_also|Alignment#} |
| 3980 | <ul> | | |
| 3981 | <li><a href="#alignment">Alignment</a></li> | | |
| 3982 | </ul> | | |
| 3983 | | | |
| 3984 | {#header_close#} | 3874 | {#header_close#} |
| 3985 | {#header_open|@cDefine#} | 3875 | {#header_open|@cDefine#} |
| 3986 | <pre><code class="zig">@cDefine(comptime name: []u8, value)</code></pre> | 3876 | <pre><code class="zig">@cDefine(comptime name: []u8, value)</code></pre> |
| ... | @@ -3999,14 +3889,7 @@ comptime { | ... | @@ -3999,14 +3889,7 @@ comptime { |
| 3999 | Use the void value, like this: | 3889 | Use the void value, like this: |
| 4000 | </p> | 3890 | </p> |
| 4001 | <pre><code class="zig">@cDefine("_GNU_SOURCE", {})</code></pre> | 3891 | <pre><code class="zig">@cDefine("_GNU_SOURCE", {})</code></pre> |
| 4002 | <p>See also:</p> | 3892 | {#see_also|Import from C Header File|@cInclude|@cImport|@cUndef|void#} |
| 4003 | <ul> | | |
| 4004 | <li><a href="#c-import">Import from C Header File</a></li> | | |
| 4005 | <li><a href="#builtin-cInclude">@cInclude</a></li> | | |
| 4006 | <li><a href="#builtin-cImport">@cImport</a></li> | | |
| 4007 | <li><a href="#builtin-cUndef">@cUndef</a></li> | | |
| 4008 | <li><a href="#void">void</a></li> | | |
| 4009 | </ul> | | |
| 4010 | {#header_close#} | 3893 | {#header_close#} |
| 4011 | {#header_open|@cImport#} | 3894 | {#header_open|@cImport#} |
| 4012 | <pre><code class="zig">@cImport(expression) -&gt; (namespace)</code></pre> | 3895 | <pre><code class="zig">@cImport(expression) -&gt; (namespace)</code></pre> |
| ... | @@ -4019,13 +3902,7 @@ comptime { | ... | @@ -4019,13 +3902,7 @@ comptime { |
| 4019 | <code>@cInclude</code>, <code>@cDefine</code>, and <code>@cUndef</code> work | 3902 | <code>@cInclude</code>, <code>@cDefine</code>, and <code>@cUndef</code> work |
| 4020 | within this expression, appending to a temporary buffer which is then parsed as C code. | 3903 | within this expression, appending to a temporary buffer which is then parsed as C code. |
| 4021 | </p> | 3904 | </p> |
| 4022 | <p>See also:</p> | 3905 | {#see_also|Import from C Header File|@cInclude|@cDefine|@cUndef#} |
| 4023 | <ul> | | |
| 4024 | <li><a href="#c-import">Import from C Header File</a></li> | | |
| 4025 | <li><a href="#builtin-cInclude">@cInclude</a></li> | | |
| 4026 | <li><a href="#builtin-cDefine">@cDefine</a></li> | | |
| 4027 | <li><a href="#builtin-cUndef">@cUndef</a></li> | | |
| 4028 | </ul> | | |
| 4029 | {#header_close#} | 3906 | {#header_close#} |
| 4030 | {#header_open|@cInclude#} | 3907 | {#header_open|@cInclude#} |
| 4031 | <pre><code class="zig">@cInclude(comptime path: []u8)</code></pre> | 3908 | <pre><code class="zig">@cInclude(comptime path: []u8)</code></pre> |
| ... | @@ -4036,13 +3913,7 @@ comptime { | ... | @@ -4036,13 +3913,7 @@ comptime { |
| 4036 | This appends <code>#include <$path>\n</code> to the <code>c_import</code> | 3913 | This appends <code>#include <$path>\n</code> to the <code>c_import</code> |
| 4037 | temporary buffer. | 3914 | temporary buffer. |
| 4038 | </p> | 3915 | </p> |
| 4039 | <p>See also:</p> | 3916 | {#see_also|Import from C Header File|@cImport|@cDefine|@cUndef#} |
| 4040 | <ul> | | |
| 4041 | <li><a href="#c-import">Import from C Header File</a></li> | | |
| 4042 | <li><a href="#builtin-cImport">@cImport</a></li> | | |
| 4043 | <li><a href="#builtin-cDefine">@cDefine</a></li> | | |
| 4044 | <li><a href="#builtin-cUndef">@cUndef</a></li> | | |
| 4045 | </ul> | | |
| 4046 | {#header_close#} | 3917 | {#header_close#} |
| 4047 | {#header_open|@cUndef#} | 3918 | {#header_open|@cUndef#} |
| 4048 | <pre><code class="zig">@cUndef(comptime name: []u8)</code></pre> | 3919 | <pre><code class="zig">@cUndef(comptime name: []u8)</code></pre> |
| ... | @@ -4053,13 +3924,7 @@ comptime { | ... | @@ -4053,13 +3924,7 @@ comptime { |
| 4053 | This appends <code>#undef $name</code> to the <code>@cImport</code> | 3924 | This appends <code>#undef $name</code> to the <code>@cImport</code> |
| 4054 | temporary buffer. | 3925 | temporary buffer. |
| 4055 | </p> | 3926 | </p> |
| 4056 | <p>See also:</p> | 3927 | {#see_also|Import from C Header File|@cImport|@cDefine|@cInclude#} |
| 4057 | <ul> | | |
| 4058 | <li><a href="#c-import">Import from C Header File</a></li> | | |
| 4059 | <li><a href="#builtin-cImport">@cImport</a></li> | | |
| 4060 | <li><a href="#builtin-cDefine">@cDefine</a></li> | | |
| 4061 | <li><a href="#builtin-cInclude">@cInclude</a></li> | | |
| 4062 | </ul> | | |
| 4063 | {#header_close#} | 3928 | {#header_close#} |
| 4064 | {#header_open|@canImplicitCast#} | 3929 | {#header_open|@canImplicitCast#} |
| 4065 | <pre><code class="zig">@canImplicitCast(comptime T: type, value) -&gt; bool</code></pre> | 3930 | <pre><code class="zig">@canImplicitCast(comptime T: type, value) -&gt; bool</code></pre> |
| ... | @@ -4091,11 +3956,7 @@ comptime { | ... | @@ -4091,11 +3956,7 @@ comptime { |
| 4091 | <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>. | 3956 | <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>. |
| 4092 | </p> | 3957 | </p> |
| 4093 | <p><code>@typeOf(ptr).alignment</code> must be <code>&gt;= @sizeOf(T).</code></p> | 3958 | <p><code>@typeOf(ptr).alignment</code> must be <code>&gt;= @sizeOf(T).</code></p> |
| 4094 | <p>See also:</p> | 3959 | {#see_also|Compile Variables#} |
| 4095 | <ul> | | |
| 4096 | <li><a href="#compile-variables">Compile Variables</a></li> | | |
| 4097 | </ul> | | |
| 4098 | | | |
| 4099 | {#header_close#} | 3960 | {#header_close#} |
| 4100 | {#header_open|@compileError#} | 3961 | {#header_open|@compileError#} |
| 4101 | <pre><code class="zig">@compileError(comptime msg: []u8)</code></pre> | 3962 | <pre><code class="zig">@compileError(comptime msg: []u8)</code></pre> |
| ... | @@ -4183,12 +4044,8 @@ test.zig:6:2: error: found compile log statement | ... | @@ -4183,12 +4044,8 @@ test.zig:6:2: error: found compile log statement |
| 4183 | <li><code>@divExact(6, 3) == 2</code></li> | 4044 | <li><code>@divExact(6, 3) == 2</code></li> |
| 4184 | <li><code>@divExact(a, b) * b == a</code></li> | 4045 | <li><code>@divExact(a, b) * b == a</code></li> |
| 4185 | </ul> | 4046 | </ul> |
| 4186 | <p>See also:</p> | 4047 | <p>For a function that returns a possible error code, use <code>@import("std").math.divExact</code>.</p> |
| 4187 | <ul> | 4048 | {#see_also|@divTrunc|@divFloor#} |
| 4188 | <li><a href="#builtin-divTrunc">@divTrunc</a></li> | | |
| 4189 | <li><a href="#builtin-divFloor">@divFloor</a></li> | | |
| 4190 | <li><code>@import("std").math.divExact</code></li> | | |
| 4191 | </ul> | | |
| 4192 | {#header_close#} | 4049 | {#header_close#} |
| 4193 | {#header_open|@divFloor#} | 4050 | {#header_open|@divFloor#} |
| 4194 | <pre><code class="zig">@divFloor(numerator: T, denominator: T) -&gt; T</code></pre> | 4051 | <pre><code class="zig">@divFloor(numerator: T, denominator: T) -&gt; T</code></pre> |
| ... | @@ -4201,12 +4058,8 @@ test.zig:6:2: error: found compile log statement | ... | @@ -4201,12 +4058,8 @@ test.zig:6:2: error: found compile log statement |
| 4201 | <li><code>@divFloor(-5, 3) == -2</code></li> | 4058 | <li><code>@divFloor(-5, 3) == -2</code></li> |
| 4202 | <li><code>@divFloor(a, b) + @mod(a, b) == a</code></li> | 4059 | <li><code>@divFloor(a, b) + @mod(a, b) == a</code></li> |
| 4203 | </ul> | 4060 | </ul> |
| 4204 | <p>See also:</p> | 4061 | <p>For a function that returns a possible error code, use <code>@import("std").math.divFloor</code>.</p> |
| 4205 | <ul> | 4062 | {#see_also|@divTrunc|@divExact#} |
| 4206 | <li><a href="#builtin-divTrunc">@divTrunc</a></li> | | |
| 4207 | <li><a href="#builtin-divExact">@divExact</a></li> | | |
| 4208 | <li><code>@import("std").math.divFloor</code></li> | | |
| 4209 | </ul> | | |
| 4210 | {#header_close#} | 4063 | {#header_close#} |
| 4211 | {#header_open|@divTrunc#} | 4064 | {#header_open|@divTrunc#} |
| 4212 | <pre><code class="zig">@divTrunc(numerator: T, denominator: T) -&gt; T</code></pre> | 4065 | <pre><code class="zig">@divTrunc(numerator: T, denominator: T) -&gt; T</code></pre> |
| ... | @@ -4219,12 +4072,8 @@ test.zig:6:2: error: found compile log statement | ... | @@ -4219,12 +4072,8 @@ test.zig:6:2: error: found compile log statement |
| 4219 | <li><code>@divTrunc(-5, 3) == -1</code></li> | 4072 | <li><code>@divTrunc(-5, 3) == -1</code></li> |
| 4220 | <li><code>@divTrunc(a, b) + @rem(a, b) == a</code></li> | 4073 | <li><code>@divTrunc(a, b) + @rem(a, b) == a</code></li> |
| 4221 | </ul> | 4074 | </ul> |
| 4222 | <p>See also:</p> | 4075 | <p>For a function that returns a possible error code, use <code>@import("std").math.divTrunc</code>.</p> |
| 4223 | <ul> | 4076 | {#see_also|@divFloor|@divExact#} |
| 4224 | <li><a href="#builtin-divFloor">@divFloor</a></li> | | |
| 4225 | <li><a href="#builtin-divExact">@divExact</a></li> | | |
| 4226 | <li><code>@import("std").math.divTrunc</code></li> | | |
| 4227 | </ul> | | |
| 4228 | {#header_close#} | 4077 | {#header_close#} |
| 4229 | {#header_open|@embedFile#} | 4078 | {#header_open|@embedFile#} |
| 4230 | <pre><code class="zig">@embedFile(comptime path: []const u8) -&gt; [X]u8</code></pre> | 4079 | <pre><code class="zig">@embedFile(comptime path: []const u8) -&gt; [X]u8</code></pre> |
| ... | @@ -4236,10 +4085,7 @@ test.zig:6:2: error: found compile log statement | ... | @@ -4236,10 +4085,7 @@ test.zig:6:2: error: found compile log statement |
| 4236 | <p> | 4085 | <p> |
| 4237 | <code>path</code> is absolute or relative to the current file, just like <code>@import</code>. | 4086 | <code>path</code> is absolute or relative to the current file, just like <code>@import</code>. |
| 4238 | </p> | 4087 | </p> |
| 4239 | <p>See also:</p> | 4088 | {#see_also|@import#} |
| 4240 | <ul> | | |
| 4241 | <li><a href="#builtin-import">@import</a></li> | | |
| 4242 | </ul> | | |
| 4243 | {#header_close#} | 4089 | {#header_close#} |
| 4244 | {#header_open|@export#} | 4090 | {#header_open|@export#} |
| 4245 | <pre><code class="zig">@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) -&gt; []const u8</code></pre> | 4091 | <pre><code class="zig">@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) -&gt; []const u8</code></pre> |
| ... | @@ -4294,10 +4140,7 @@ test.zig:6:2: error: found compile log statement | ... | @@ -4294,10 +4140,7 @@ test.zig:6:2: error: found compile log statement |
| 4294 | <p> | 4140 | <p> |
| 4295 | <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>. | 4141 | <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>. |
| 4296 | </p> | 4142 | </p> |
| 4297 | <p>See also:</p> | 4143 | {#see_also|Compile Variables#} |
| 4298 | <ul> | | |
| 4299 | <li><a href="#compile-variables">Compile Variables</a></li> | | |
| 4300 | </ul> | | |
| 4301 | {#header_close#} | 4144 | {#header_close#} |
| 4302 | {#header_open|@fieldParentPtr#} | 4145 | {#header_open|@fieldParentPtr#} |
| 4303 | <pre><code class="zig">@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8, | 4146 | <pre><code class="zig">@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8, |
| ... | @@ -4338,11 +4181,7 @@ test.zig:6:2: error: found compile log statement | ... | @@ -4338,11 +4181,7 @@ test.zig:6:2: error: found compile log statement |
| 4338 | <li><code>@import("std")</code> - Zig Standard Library</li> | 4181 | <li><code>@import("std")</code> - Zig Standard Library</li> |
| 4339 | <li><code>@import("builtin")</code> - Compiler-provided types and variables</li> | 4182 | <li><code>@import("builtin")</code> - Compiler-provided types and variables</li> |
| 4340 | </ul> | 4183 | </ul> |
| 4341 | <p>See also:</p> | 4184 | {#see_also|Compile Variables|@embedFile#} |
| 4342 | <ul> | | |
| 4343 | <li><a href="#compile-variables">Compile Variables</a></li> | | |
| 4344 | <li><a href="#builtin-embedFile">@embedFile</a></li> | | |
| 4345 | </ul> | | |
| 4346 | {#header_close#} | 4185 | {#header_close#} |
| 4347 | {#header_open|@inlineCall#} | 4186 | {#header_open|@inlineCall#} |
| 4348 | <pre><code class="zig">@inlineCall(function: X, args: ...) -&gt; Y</code></pre> | 4187 | <pre><code class="zig">@inlineCall(function: X, args: ...) -&gt; Y</code></pre> |
| ... | @@ -4359,10 +4198,7 @@ fn add(a: i32, b: i32) -&gt; i32 { a + b }</code></pre> | ... | @@ -4359,10 +4198,7 @@ fn add(a: i32, b: i32) -&gt; i32 { a + b }</code></pre> |
| 4359 | Unlike a normal function call, however, <code>@inlineCall</code> guarantees that the call | 4198 | Unlike a normal function call, however, <code>@inlineCall</code> guarantees that the call |
| 4360 | will be inlined. If the call cannot be inlined, a compile error is emitted. | 4199 | will be inlined. If the call cannot be inlined, a compile error is emitted. |
| 4361 | </p> | 4200 | </p> |
| 4362 | <p>See also:</p> | 4201 | {#see_also|@noInlineCall#} |
| 4363 | <ul> | | |
| 4364 | <li><a href="#builtin-noInlineCall">@noInlineCall</a></li> | | |
| 4365 | </ul> | | |
| 4366 | {#header_close#} | 4202 | {#header_close#} |
| 4367 | {#header_open|@intToPtr#} | 4203 | {#header_open|@intToPtr#} |
| 4368 | <pre><code class="zig">@intToPtr(comptime DestType: type, int: usize) -&gt; DestType</code></pre> | 4204 | <pre><code class="zig">@intToPtr(comptime DestType: type, int: usize) -&gt; DestType</code></pre> |
| ... | @@ -4454,11 +4290,8 @@ mem.set(u8, dest, c);</code></pre> | ... | @@ -4454,11 +4290,8 @@ mem.set(u8, dest, c);</code></pre> |
| 4454 | <li><code>@mod(-5, 3) == 1</code></li> | 4290 | <li><code>@mod(-5, 3) == 1</code></li> |
| 4455 | <li><code>@divFloor(a, b) + @mod(a, b) == a</code></li> | 4291 | <li><code>@divFloor(a, b) + @mod(a, b) == a</code></li> |
| 4456 | </ul> | 4292 | </ul> |
| 4457 | <p>See also:</p> | 4293 | <p>For a function that returns an error code, see <code>@import("std").math.mod</code>.</p> |
| 4458 | <ul> | 4294 | {#see_also|@rem#} |
| 4459 | <li><a href="#builtin-rem">@rem</a></li> | | |
| 4460 | <li><code>@import("std").math.mod</code></li> | | |
| 4461 | </ul> | | |
| 4462 | {#header_close#} | 4295 | {#header_close#} |
| 4463 | {#header_open|@mulWithOverflow#} | 4296 | {#header_open|@mulWithOverflow#} |
| 4464 | <pre><code class="zig">@mulWithOverflow(comptime T: type, a: T, b: T, result: &amp;T) -&gt; bool</code></pre> | 4297 | <pre><code class="zig">@mulWithOverflow(comptime T: type, a: T, b: T, result: &amp;T) -&gt; bool</code></pre> |
| ... | @@ -4483,10 +4316,7 @@ fn add(a: i32, b: i32) -&gt; i32 { a + b }</code></pre> | ... | @@ -4483,10 +4316,7 @@ fn add(a: i32, b: i32) -&gt; i32 { a + b }</code></pre> |
| 4483 | Unlike a normal function call, however, <code>@noInlineCall</code> guarantees that the call | 4316 | Unlike a normal function call, however, <code>@noInlineCall</code> guarantees that the call |
| 4484 | will not be inlined. If the call must be inlined, a compile error is emitted. | 4317 | will not be inlined. If the call must be inlined, a compile error is emitted. |
| 4485 | </p> | 4318 | </p> |
| 4486 | <p>See also:</p> | 4319 | {#see_also|@inlineCall#} |
| 4487 | <ul> | | |
| 4488 | <li><a href="#builtin-inlineCall">@inlineCall</a></li> | | |
| 4489 | </ul> | | |
| 4490 | {#header_close#} | 4320 | {#header_close#} |
| 4491 | {#header_open|@offsetOf#} | 4321 | {#header_open|@offsetOf#} |
| 4492 | <pre><code class="zig">@offsetOf(comptime T: type, comptime field_name: [] const u8) -&gt; (number literal)</code></pre> | 4322 | <pre><code class="zig">@offsetOf(comptime T: type, comptime field_name: [] const u8) -&gt; (number literal)</code></pre> |
| ... | @@ -4529,11 +4359,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4529,11 +4359,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4529 | <li>From library code, calling the programmer's panic function if they exposed one in the root source file.</li> | 4359 | <li>From library code, calling the programmer's panic function if they exposed one in the root source file.</li> |
| 4530 | <li>When mixing C and Zig code, calling the canonical panic implementation across multiple .o files.</li> | 4360 | <li>When mixing C and Zig code, calling the canonical panic implementation across multiple .o files.</li> |
| 4531 | </ul> | 4361 | </ul> |
| 4532 | <p>See also:</p> | 4362 | {#see_also|Root Source File#} |
| 4533 | <ul> | | |
| 4534 | <li><a href="#root-source-file">Root Source File</a></li> | | |
| 4535 | </ul> | | |
| 4536 | | | |
| 4537 | {#header_close#} | 4363 | {#header_close#} |
| 4538 | {#header_open|@ptrCast#} | 4364 | {#header_open|@ptrCast#} |
| 4539 | <pre><code class="zig">@ptrCast(comptime DestType: type, value: var) -&gt; DestType</code></pre> | 4365 | <pre><code class="zig">@ptrCast(comptime DestType: type, value: var) -&gt; DestType</code></pre> |
| ... | @@ -4565,11 +4391,8 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4565,11 +4391,8 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4565 | <li><code>@rem(-5, 3) == -2</code></li> | 4391 | <li><code>@rem(-5, 3) == -2</code></li> |
| 4566 | <li><code>@divTrunc(a, b) + @rem(a, b) == a</code></li> | 4392 | <li><code>@divTrunc(a, b) + @rem(a, b) == a</code></li> |
| 4567 | </ul> | 4393 | </ul> |
| 4568 | <p>See also:</p> | 4394 | <p>For a function that returns an error code, see <code>@import("std").math.rem</code>.</p> |
| 4569 | <ul> | 4395 | {#see_also|@mod#} |
| 4570 | <li><a href="#builtin-mod">@mod</a></li> | | |
| 4571 | <li><code>@import("std").math.rem</code></li> | | |
| 4572 | </ul> | | |
| 4573 | {#header_close#} | 4396 | {#header_close#} |
| 4574 | {#header_open|@returnAddress#} | 4397 | {#header_open|@returnAddress#} |
| 4575 | <pre><code class="zig">@returnAddress()</code></pre> | 4398 | <pre><code class="zig">@returnAddress()</code></pre> |
| ... | @@ -4584,7 +4407,6 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4584,7 +4407,6 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4584 | <p> | 4407 | <p> |
| 4585 | This function is only valid within function scope. | 4408 | This function is only valid within function scope. |
| 4586 | </p> | 4409 | </p> |
| 4587 | | | |
| 4588 | {#header_close#} | 4410 | {#header_close#} |
| 4589 | {#header_open|@setDebugSafety#} | 4411 | {#header_open|@setDebugSafety#} |
| 4590 | <pre><code class="zig">@setDebugSafety(scope, safety_on: bool)</code></pre> | 4412 | <pre><code class="zig">@setDebugSafety(scope, safety_on: bool)</code></pre> |
| ... | @@ -4623,11 +4445,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4623,11 +4445,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4623 | <pre><code class="sh">$ ./zig build-obj test.zig</code></pre> | 4445 | <pre><code class="sh">$ ./zig build-obj test.zig</code></pre> |
| 4624 | <p>(no output because it worked fine)</p> | 4446 | <p>(no output because it worked fine)</p> |
| 4625 | | 4447 | |
| 4626 | <p>See also:</p> | 4448 | {#see_also|comptime#} |
| 4627 | <ul> | | |
| 4628 | <li><a href="#comptime">comptime</a></li> | | |
| 4629 | </ul> | | |
| 4630 | | | |
| 4631 | {#header_close#} | 4449 | {#header_close#} |
| 4632 | {#header_open|@setFloatMode#} | 4450 | {#header_open|@setFloatMode#} |
| 4633 | <pre><code class="zig">@setFloatMode(scope, mode: @import("builtin").FloatMode)</code></pre> | 4451 | <pre><code class="zig">@setFloatMode(scope, mode: @import("builtin").FloatMode)</code></pre> |
| ... | @@ -4655,21 +4473,14 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4655,21 +4473,14 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4655 | <code>Strict</code> - Floating point operations follow strict IEEE compliance. | 4473 | <code>Strict</code> - Floating point operations follow strict IEEE compliance. |
| 4656 | </li> | 4474 | </li> |
| 4657 | </ul> | 4475 | </ul> |
| 4658 | <p>See also:</p> | 4476 | {#see_also|Floating Point Operations#} |
| 4659 | <ul> | | |
| 4660 | <li><a href="#float-operations">Floating Point Operations</a></li> | | |
| 4661 | </ul> | | |
| 4662 | | | |
| 4663 | {#header_close#} | 4477 | {#header_close#} |
| 4664 | {#header_open|@setGlobalLinkage#} | 4478 | {#header_open|@setGlobalLinkage#} |
| 4665 | <pre><code class="zig">@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage)</code></pre> | 4479 | <pre><code class="zig">@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage)</code></pre> |
| 4666 | <p> | 4480 | <p> |
| 4667 | <code>GlobalLinkage</code> can be found with <code>@import("builtin").GlobalLinkage</code>. | 4481 | <code>GlobalLinkage</code> can be found with <code>@import("builtin").GlobalLinkage</code>. |
| 4668 | </p> | 4482 | </p> |
| 4669 | <p>See also:</p> | 4483 | {#see_also|Compile Variables#} |
| 4670 | <ul> | | |
| 4671 | <li><a href="#compile-variables">Compile Variables</a></li> | | |
| 4672 | </ul> | | |
| 4673 | {#header_close#} | 4484 | {#header_close#} |
| 4674 | {#header_open|@setGlobalSection#} | 4485 | {#header_open|@setGlobalSection#} |
| 4675 | <pre><code class="zig">@setGlobalSection(global_variable_name, comptime section_name: []const u8) -&gt; bool</code></pre> | 4486 | <pre><code class="zig">@setGlobalSection(global_variable_name, comptime section_name: []const u8) -&gt; bool</code></pre> |
| ... | @@ -4687,11 +4498,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4687,11 +4498,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4687 | The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits. | 4498 | The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits. |
| 4688 | This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior. | 4499 | This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior. |
| 4689 | </p> | 4500 | </p> |
| 4690 | <p>See also:</p> | 4501 | {#see_also|@shrExact|@shlWithOverflow#} |
| 4691 | <ul> | | |
| 4692 | <li><a href="#builtin-shrExact">@shrExact</a></li> | | |
| 4693 | <li><a href="#builtin-shlWithOverflow">@shlWithOverflow</a></li> | | |
| 4694 | </ul> | | |
| 4695 | {#header_close#} | 4502 | {#header_close#} |
| 4696 | {#header_open|@shlWithOverflow#} | 4503 | {#header_open|@shlWithOverflow#} |
| 4697 | <pre><code class="zig">@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: &amp;T) -&gt; bool</code></pre> | 4504 | <pre><code class="zig">@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: &amp;T) -&gt; bool</code></pre> |
| ... | @@ -4704,11 +4511,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4704,11 +4511,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4704 | The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits. | 4511 | The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits. |
| 4705 | This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior. | 4512 | This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior. |
| 4706 | </p> | 4513 | </p> |
| 4707 | <p>See also:</p> | 4514 | {#see_also|@shlExact|@shrExact#} |
| 4708 | <ul> | | |
| 4709 | <li><a href="#builtin-shlExact">@shlExact</a></li> | | |
| 4710 | <li><a href="#builtin-shrExact">@shrExact</a></li> | | |
| 4711 | </ul> | | |
| 4712 | {#header_close#} | 4515 | {#header_close#} |
| 4713 | {#header_open|@shrExact#} | 4516 | {#header_open|@shrExact#} |
| 4714 | <pre><code class="zig">@shrExact(value: T, shift_amt: Log2T) -&gt; T</code></pre> | 4517 | <pre><code class="zig">@shrExact(value: T, shift_amt: Log2T) -&gt; T</code></pre> |
| ... | @@ -4720,10 +4523,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' | ... | @@ -4720,10 +4523,7 @@ test.zig:5:9: error: expected type '&amp;Derp', found '&amp;Wat' |
| 4720 | The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits. | 4523 | The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits. |
| 4721 | This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior. | 4524 | This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior. |
| 4722 | </p> | 4525 | </p> |
| 4723 | <p>See also:</p> | 4526 | {#see_also|@shlExact|@shlWithOverflow#} |
| 4724 | <ul> | | |
| 4725 | <li><a href="#builtin-shlExact">@shlExact</a></li> | | |
| 4726 | </ul> | | |
| 4727 | {#header_close#} | 4527 | {#header_close#} |
| 4728 | {#header_open|@sizeOf#} | 4528 | {#header_open|@sizeOf#} |
| 4729 | <pre><code class="zig">@sizeOf(comptime T: type) -&gt; (number literal)</code></pre> | 4529 | <pre><code class="zig">@sizeOf(comptime T: type) -&gt; (number literal)</code></pre> |
| ... | @@ -4863,12 +4663,7 @@ pub fn build(b: &amp;Builder) { | ... | @@ -4863,12 +4663,7 @@ pub fn build(b: &amp;Builder) { |
| 4863 | <li>Safety checks enabled</li> | 4663 | <li>Safety checks enabled</li> |
| 4864 | <li>Slow compilation speed</li> | 4664 | <li>Slow compilation speed</li> |
| 4865 | </ul> | 4665 | </ul> |
| 4866 | <p>See also:</p> | 4666 | {#see_also|Compile Variables|Zig Build System|Undefined Behavior#} |
| 4867 | <ul> | | |
| 4868 | <li><a href="#compile-variables">Compile Variables</a></li> | | |
| 4869 | <li><a href="#zig-build-system">Zig Build System</a></li> | | |
| 4870 | <li><a href="#undefined-behavior">Undefined Behavior</a></li> | | |
| 4871 | </ul> | | |
| 4872 | {#header_close#} | 4667 | {#header_close#} |
| 4873 | {#header_close#} | 4668 | {#header_close#} |
| 4874 | {#header_open|Undefined Behavior#} | 4669 | {#header_open|Undefined Behavior#} |
| ... | @@ -5234,10 +5029,7 @@ comptime { | ... | @@ -5234,10 +5029,7 @@ comptime { |
| 5234 | <p>TODO: importance of checking for allocation failure</p> | 5029 | <p>TODO: importance of checking for allocation failure</p> |
| 5235 | <p>TODO: mention overcommit and the OOM Killer</p> | 5030 | <p>TODO: mention overcommit and the OOM Killer</p> |
| 5236 | <p>TODO: mention recursion</p> | 5031 | <p>TODO: mention recursion</p> |
| 5237 | <p>See also:</p> | 5032 | {#see_also|Pointers#} |
| 5238 | <ul> | | |
| 5239 | <li><a href="#pointers">Pointers</a></li> | | |
| 5240 | </ul> | | |
| 5241 | | 5033 | |
| 5242 | {#header_close#} | 5034 | {#header_close#} |
| 5243 | {#header_open|Compile Variables#} | 5035 | {#header_open|Compile Variables#} |
| ... | @@ -5406,10 +5198,7 @@ pub const object_format = ObjectFormat.elf; | ... | @@ -5406,10 +5198,7 @@ pub const object_format = ObjectFormat.elf; |
| 5406 | pub const mode = Mode.ReleaseFast; | 5198 | pub const mode = Mode.ReleaseFast; |
| 5407 | pub const link_libs = [][]const u8 { | 5199 | pub const link_libs = [][]const u8 { |
| 5408 | };</code></pre> | 5200 | };</code></pre> |
| 5409 | <p>See also:</p> | 5201 | {#see_also|Build Mode#} |
| 5410 | <ul> | | |
| 5411 | <li><a href="#build-mode">Build Mode</a></li> | | |
| 5412 | </ul> | | |
| 5413 | {#header_close#} | 5202 | {#header_close#} |
| 5414 | {#header_open|Root Source File#} | 5203 | {#header_open|Root Source File#} |
| 5415 | <p>TODO: explain how root source file finds other files</p> | 5204 | <p>TODO: explain how root source file finds other files</p> |
| ... | @@ -5456,10 +5245,7 @@ pub const link_libs = [][]const u8 { | ... | @@ -5456,10 +5245,7 @@ pub const link_libs = [][]const u8 { |
| 5456 | <li><code>c_longdouble</code></li> | 5245 | <li><code>c_longdouble</code></li> |
| 5457 | <li><code>c_void</code></li> | 5246 | <li><code>c_void</code></li> |
| 5458 | </ul> | 5247 | </ul> |
| 5459 | <p>See also:</p> | 5248 | {#see_also|Primitive Types#} |
| 5460 | <ul> | | |
| 5461 | <li><a href="#primitive-types">Primitive Types</a></li> | | |
| 5462 | </ul> | | |
| 5463 | {#header_close#} | 5249 | {#header_close#} |
| 5464 | {#header_open|C String Literals#} | 5250 | {#header_open|C String Literals#} |
| 5465 | <pre><code class="zig">extern fn puts(&amp;const u8); | 5251 | <pre><code class="zig">extern fn puts(&amp;const u8); |
| ... | @@ -5472,10 +5258,7 @@ pub fn main() -&gt; %void { | ... | @@ -5472,10 +5258,7 @@ pub fn main() -&gt; %void { |
| 5472 | c\\multiline C string literal | 5258 | c\\multiline C string literal |
| 5473 | ); | 5259 | ); |
| 5474 | }</code></pre> | 5260 | }</code></pre> |
| 5475 | <p>See also:</p> | 5261 | {#see_also|String Literals#} |
| 5476 | <ul> | | |
| 5477 | <li><a href="#string-literals">String Literals</a></li> | | |
| 5478 | </ul> | | |
| 5479 | {#header_close#} | 5262 | {#header_close#} |
| 5480 | {#header_open|Import from C Header File#} | 5263 | {#header_open|Import from C Header File#} |
| 5481 | <p> | 5264 | <p> |
| ... | @@ -5504,14 +5287,7 @@ const c = @cImport({ | ... | @@ -5504,14 +5287,7 @@ const c = @cImport({ |
| 5504 | } | 5287 | } |
| 5505 | @cInclude("soundio.h"); | 5288 | @cInclude("soundio.h"); |
| 5506 | });</code></pre> | 5289 | });</code></pre> |
| 5507 | <p>See also:</p> | 5290 | {#see_also|@cImport|@cInclude|@cDefine|@cUndef|@import#} |
| 5508 | <ul> | | |
| 5509 | <li><a href="#builtin-cImport">@cImport</a></li> | | |
| 5510 | <li><a href="#builtin-cInclude">@cInclude</a></li> | | |
| 5511 | <li><a href="#builtin-cDefine">@cDefine</a></li> | | |
| 5512 | <li><a href="#builtin-cUndef">@cUndef</a></li> | | |
| 5513 | <li><a href="#builtin-import">@import</a></li> | | |
| 5514 | </ul> | | |
| 5515 | {#header_close#} | 5291 | {#header_close#} |
| 5516 | {#header_open|Mixing Object Files#} | 5292 | {#header_open|Mixing Object Files#} |
| 5517 | <p> | 5293 | <p> |
| ... | @@ -5571,11 +5347,7 @@ pub fn build(b: &amp;Builder) { | ... | @@ -5571,11 +5347,7 @@ pub fn build(b: &amp;Builder) { |
| 5571 | <pre><code class="sh">$ zig build | 5347 | <pre><code class="sh">$ zig build |
| 5572 | $ ./test | 5348 | $ ./test |
| 5573 | all your base are belong to us</code></pre> | 5349 | all your base are belong to us</code></pre> |
| 5574 | <p>See also:</p> | 5350 | {#see_also|Targets|Zig Build System#} |
| 5575 | <ul> | | |
| 5576 | <li><a href="#targets">Targets</a></li> | | |
| 5577 | <li><a href="#zig-build-system">Zig Build System</a></li> | | |
| 5578 | </ul> | | |
| 5579 | {#header_close#} | 5351 | {#header_close#} |
| 5580 | {#header_close#} | 5352 | {#header_close#} |
| 5581 | {#header_open|Targets#} | 5353 | {#header_open|Targets#} |