Jens Gustedt's Blog

programming in modern C


C11

  • Defer available in gcc and clang

    About a year ago I posted about defer and that it would be available for everyone using gcc and/or clang soon. So it is probably time for an update. Two things have happened in the mean time: I have not yet got my hands on the gcc implementation (but this is also less urgent, see… Continue reading

  • #include __FILE__

    Include recursion in C is possible and useful. Continue reading

  • Early access to the C23 edition of Modern C

    Manning’s early access program (MEAP) for the new edition is now openat https://www.manning.com/books/modern-c-third-edition There is a special code mlgustedt2 to get 45% off of the official price. This is currently limited until Jan 31. Continue reading

  • C source-to-source compiler enhancement from within

    A new research report describing shnell has now appeared on HAL: https://hal.inria.fr/hal-02998412 We show how locally replaceable code snippets can be used to easily specify and prototype compiler and language enhancements for the C language that work by local source-to-source transformation. A toolbox implements the feature and provides many directives that can be used for… Continue reading

  • Modern C, Second Edition

    A new edition of the book Modern C and much more are now available under a CC license via the following page https://gustedt.gitlabpages.inria.fr/modern-c/  This edition is the result of a collaboration with Manning, and improves a lot over the previous edition; material has been rewritten and reordered, a lot of graphics have been added. Manning… Continue reading

    ,
  • Spurious failures of thread functions

    C11’s thread interface was not very clear on failure conditions that some functions might encounter. It was not clear that wait functions for conditional variables (cnd_t) and tentative locking of mutexes (mtx_t) may fail spuriously, that is with not apparent reason for the caller. By lack of such a specification, it was not clear how… Continue reading

  • compare exchange compares memory and not value

    In C11, 7.17.7.4, introduces atomic_compare_exchange generic functions. These are precious tools when using atomics: they allow to conditionally store new data in an atomic variable and to retrieve a previous value of it, eventually. You can see that as a generalization of atomic_fetch_and_add where we are also able to retrieve a counter value and change… Continue reading

  • C17: reformulations for atomic_flag

    In C11, there was a problem with the fact that atomic_flag is one of the rare types that is not considered to have a value, but it only has state (clear and set) which is changed via function calls. (mtx_t and cnd_t are other examples of such types.) There was no established relation between these… Continue reading

  • C17: rvalues and function types drop qualifiers

    At least since C99 the C standard has: The properties associated with qualified types are meaningful only for expressions that are lvalues. This phrase expresses the intent that type qualifiers are to be ignored in “some sense” if they appear in other contexts, namely for the values of expressions, i.e. rvalues. Until the invention of… Continue reading

  • C17

    C17 is a “bugfix release” of the C standard. Whereas the intention of the C working group (WG14) has been that this release does not introduce normative changes (but one), it brings a lot of clarifications all over the place. By adopting this version, some features as implemented by some compilers may change if their… Continue reading

Design a site like this with WordPress.com
Get started