Overview
| Artifact ID: | 5f4e397bc54048d36c0af95fd126347400e7bc1aa29ca8730370bda676914e8e |
|---|---|
| Page Name: | branch/c-std-update |
| Date: | 2025-11-17 16:40:03 |
| Original User: | dkf |
| Mimetype: | text/x-markdown |
| Parent: | 4c96ea7c8629917b754438133f23a4d1ad643b9103ae887352f3568890300925 (diff) |
| Next | 5128b17681b52f85bc96b16ea2d861e103bd7d74d97291a30ec7d97efcb891a7 |
Content
This branch is looking at the things we can do by adopting C11 features (as opposed to just C89) more consistently.
The following branches (organised by enabling underlying language feature) are (mostly) derived from this one. They're organised by the basic underlying enabling feature of C11 that permits them:
- Feature: Anonymous Structure Members
- Feature: Booleans
- Feature: Comments with //
- There is no branch for changing comment styles (
/* ... */to// ...); we can, but it makes no sense to prioritise doing so at all and it makes only the smallest of readability difference. Change when it makes sense to do it as part of some other activity, not before. (Note however that this comment style has been sneaking into Tcl for some time; it crops up in quite a few places in the 9.0 codebase.)
- There is no branch for changing comment styles (
- Feature: Flexible Variable Declarations
c11-tcloo-foreachc11-full-hash-foreach(extended version)
- Moving variable declarations around inside functions isn't very high value and yet is very noisy. Outside of doing things like making iteration neater (in the branches above, where the demonstrated gains are stronger), it's not worth putting a lot of effort into specifically, but can easily be done incrementally as part of other work.
- Feature: Inline Functions
- Widely used in Tcl for many years.
- Feature: New Types
- We ought to support
<stdint.h>more, especially intclLink.c. (This would also be a good opportunity for using type-generic trickery.) - We can ignore complex numbers entirely; we were doing that already anyway.
- The alignment type
max_align_twould be useful, but isn't supported by MSVC for obscure reasons.
- We ought to support
- Feature: Type-Generic Functions
c11-generic-oo-api; public API change.- This would be a useful thing to use with
tclLink.c; that's also a public API change.
- Feature: Non-Constant Compound Values
c11-array-literals- Note that
c11-tcloo-foreachalso uses this feature to get the declaration semantics right.
- Feature: Restrict Qualification of Function Arguments
- Compilers tend to handle most of our functions by assuming restriction based on argument types. There's a few places it might be worthwhile.
- Feature: Varargs Macros
- Feature: Variable Length Arrays
- Not recommended for use. Compiler support is far too patchy and we explicitly don't want to stress the C stack.
Note! None of these changes are altering the public API (or ABI) of Tcl. It is our intention to keep that working with a wider range of C versions, as well as with C++ and Objective-C (either of which may be used internally by Tk).