docs/src/modules.md

changeset 325
a3e63cb21e20
parent 321
9af21a50b516
child 326
3dd7d21fb76b
equal deleted inserted replaced
324:343bff4cc0b5 325:a3e63cb21e20
578 578
579 /* (3) S() macro creates sstr_t from a string using sizeof() and using sstrn(). 579 /* (3) S() macro creates sstr_t from a string using sizeof() and using sstrn().
580 This version is especially useful for function arguments */ 580 This version is especially useful for function arguments */
581 sstr_t c = S("hello"); 581 sstr_t c = S("hello");
582 582
583 /* (4) ST() macro creates sstr_t struct literal using sizeof() */ 583 /* (4) SC() macro works like S(), but makes the string immutable using scstr_t.
584 sstr_t d = ST("hello"); 584 (available since UCX 2.0) */
585 ``` 585 scstr_t d = SC("hello");
586 586
587 You should not use the `S()` or `ST()` macro with string of unknown origin, 587 /* (5) ST() macro creates sstr_t struct literal using sizeof() */
588 since the `sizeof()` call might not coincide with the string length in those 588 sstr_t e = ST("hello");
589 cases. If you know what you are doing, it can save you some performance, 589 ```
590
591 You should not use the `S()`, `SC()`, or `ST()` macro with string of unknown
592 origin, since the `sizeof()` call might not coincide with the string length in
593 those cases. If you know what you are doing, it can save you some performance,
590 because you do not need the `strlen()` call. 594 because you do not need the `strlen()` call.
591 595
592 ### Handling immutable strings 596 ### Handling immutable strings
593 597
594 *(Since: UCX 2.0)* 598 *(Since: UCX 2.0)*
653 some 657 some
654 strings 658 strings
655 659
656 The memory pool ensures, that all strings are freed. 660 The memory pool ensures, that all strings are freed.
657 661
662 ### Disabling convenience macros
663
664 If you are experiencing any troubles with the short convenience macros `S()`,
665 `SC()`, or `ST()`, you can disable them by setting the macro
666 `UCX_NO_SSTR_SHORTCUTS` before including the header (or via a compiler option).
667 For the formatting macros `SFMT()` and `PRIsstr` you can use the macro
668 `UCX_NO_SSTR_FORMAT_MACROS` to disable them.
669
670 Please keep in mind, that after disabling the macros, you cannot use them in
671 your code *and* foreign code that you might have included.
672 You should only disable the macros, if you are experiencing a nasty name clash
673 which cannot be otherwise resolved.
674
658 ## Testing 675 ## Testing
659 676
660 *Header file:* [test.h](api/test_8h.html) 677 *Header file:* [test.h](api/test_8h.html)
661 *Required modules:* None. 678 *Required modules:* None.
662 679

mercurial