Modern C is now feature complete

You find the latest version of my book at the usual place at

http://icube-icps.unistra.fr/index.php/File:ModernC.pdf

This now contains all the material that I plan to put into it. New are “experience” parts about performance, function-like macros and _Generic, control flow, threads and atomics. There is in particular a section about memory consistency, probably the most difficult write-up for this book.

These higher level parts have not yet have had the reading they hopefully deserve, so please give it a try. As before, constructive feedback is highly welcome. Thanks to everybody who already did send me comments and corrections!

Constructive comments to this blog are welcome.

This is not the right place for

  • feedback about details (missing commas, spelling errors). If you have such details, please collect them and send them to me directly.
  • rants against the C standard. This is not the place to let off steam nor to compare to whatever other programming language you prefer. If you have criticism about the C standard, please contribute. The C standards committee is a nice batch of people, don’t be afraid. And if you have concrete proposals, also it would be much better to contact me (or any other member of the committee) directly and see how you may invest yourself in the ISO process.

Also, comments that come from real people are highly preferred.

Advertisements

24 thoughts on “Modern C is now feature complete”

  1. Thanks a lot, Jens! Your work is a breath of fresh air amidst bunch of those “Modern C” books.

  2. Thanks, Jens! I have installed clang and gcc on windows 7 and to get your first program to work correctly I had to change %zu to %d and size_t i to int i

    1. You really shouldn’t have to, these are around for so long …
      Windows has a long time history of really bad support for decent C. Hopefully more modern systems than Windows 7 will catch up.
      There should be other environments for programming with C on windows that don’t have these problems.

    2. That is a problem with the way MinGW does things. Use the options -std=c11 -D__USE_MINGW_ANSI_STDIO while compiling to solve it.

  3. Thank you for sharing this book and making it available to everyone. Are you planning to publish this in .epub format too? That will be immensely useful.

    1. I imagine that it would be useful. I have two technical problems with it.
      The first would be to find a tool chain to produce this with LaTeX. If you know how that works or would even be willing to do it, that could be very useful.
      The second is that doing the layout for that would probably be quite difficult. Already as it is now, there are overflowing lines, and doing the layout of the code such that it fits on A4 and still is readable is a challenge.
      This is why we will probably also stick to this size for the print version.

      1. Jens this is an amazing work. Really a good book for everyone that would like to pick a solid base of modern C. If I may just leave a suggestion, though, it will be a great idea to tweak the LaTeX template a bit and make the book look even more modern. The TeX community at StackExchange is always source of great inspiration (e.g. http://tex.stackexchange.com/questions/1319/). This great content deserve a great carrier. 🙂

        1. Hm, I am more a fan of being modern than looking modern 🙂
          For the final LaTeX style, I don’t really know yet how this is going to be. The people from the publishing house have their own macros that I didn’t apply, yet. So we will see how this will look, then.

      2. Can you please provide me a compilable .tex snippet containing your code blocks to work with. I can try using pandoc to generate epub and see how that turns out.

        1. There is really nothing particular there. This is native C code with listing style. The problem really is that for code it has to be fixed lines.
          But I can easily give you access if you want to try things out. Please contact me through mail, then.

  4. @jens I would love to buy this book for my Kindle. Are there any plans to publish?

  5. In the first code example, you have “/* This may look like nonsense, but really is -*- mode: C -*- */”. You are using Emacs! 🙂 By any chance, was the original document source in org, and then covered to LaTeX?

  6. Any chance the code listings will be available in separate text files so they won’t need to be retyped?

    1. Yes, this is the idea. Though I have not yet made up my mind how and where to make this accessible.
      Perhaps I should put up a site for the book. Would probably also be good just to download the pdf, our institutional server had trouble to cope with all the traffic.

  7. In line 4 of the code in section 12.7 you mention the file “crash.h”, Do you know where it can be found?

    Thanks – Will

  8. Hello! I read the book, compiled April and have found possible errors (missing letters, misspelled words, etc). I have compiled a list for you. How can I contact you, or can you contact me, so that i can send it to you if you wish?

Comments are closed.