Jens Gustedt's Blog

November 25, 2016

Modern C is now feature complete

Filed under: C11, C99, language — Jens Gustedt @ 13:21

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 Comments »

  1. Thanks, Jens! I have enjoyed the past revisions. I will check the new additions.

    Comment by Javier — November 25, 2016 @ 20:16

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

    Comment by teners — November 28, 2016 @ 09:35

  3. 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

    Comment by Allan Nelson — November 28, 2016 @ 17:38

    • 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.

      Comment by Jens Gustedt — November 28, 2016 @ 17:46

    • 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.

      Comment by Anonymous — November 28, 2016 @ 19:47

  4. 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.

    Comment by Kaushal — November 28, 2016 @ 22:02

    • 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.

      Comment by Jens Gustedt — November 28, 2016 @ 22:11

      • 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. 🙂

        Comment by PaoloUni — November 29, 2016 @ 00:07

        • 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.

          Comment by Jens Gustedt — November 29, 2016 @ 00:19

      • 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.

        Comment by Kaushal — November 29, 2016 @ 00:43

        • 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.

          Comment by Jens Gustedt — November 29, 2016 @ 07:59

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

    Comment by Michael Christenson II — November 29, 2016 @ 06:00

    • Did you read the cover page ?)
      Yes, this will be published also in print.
      As ebook we will have to see.

      Comment by Jens Gustedt — November 29, 2016 @ 07:55

  6. 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?

    Comment by Kaushal — November 29, 2016 @ 07:52

    • No, I didn’t use org mode for this. I think that a book is too complex for that.

      Comment by Jens Gustedt — November 29, 2016 @ 07:57

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

    Comment by Ryne Everett — November 30, 2016 @ 18:45

    • 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.

      Comment by Jens Gustedt — November 30, 2016 @ 18:57

  8. Thanks for the great work.

    Comment by DaboD — February 19, 2017 @ 16:58

  9. 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

    Comment by C W Rose — April 13, 2017 @ 13:32

    • Hello,
      I took the ideas/code from Ygdrasil’s blog

      Sorry, I yet didn’t came around to make all the code accessible through a web page. Please contact me directly if you want to have it sent by email.
      Jens

      Comment by Jens Gustedt — April 13, 2017 @ 13:52

  10. Yes, I’d searched that blog and not found the relevant file. Never mind.

    Will

    Comment by C W Rose — April 20, 2017 @ 10:08

  11. 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?

    Comment by bourne — June 5, 2017 @ 17:54

    • please send it by mail, you should have no problem to find my address

      Comment by Jens Gustedt — June 5, 2017 @ 19:52

      • You should’ve received it already. Hope it helps.

        Comment by bourne — June 5, 2017 @ 20:36


RSS feed for comments on this post.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.