You find the latest version of my book at the usual place at
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.
24 thoughts on “Modern C is now feature complete”
Thanks, Jens! I have enjoyed the past revisions. I will check the new additions.
Thanks a lot, Jens! Your work is a breath of fresh air amidst bunch of those “Modern C” books.
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
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.
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.
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.
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.
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. 🙂
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.
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.
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.
@jens I would love to buy this book for my Kindle. Are there any plans to publish?
Did you read the cover page ?)
Yes, this will be published also in print.
As ebook we will have to see.
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?
No, I didn’t use org mode for this. I think that a book is too complex for that.
Any chance the code listings will be available in separate text files so they won’t need to be retyped?
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.
Thanks for the great work.
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
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.
Yes, I’d searched that blog and not found the relevant file. Never mind.
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?
please send it by mail, you should have no problem to find my address
You should’ve received it already. Hope it helps.
Comments are closed.