Books on C
February 11, 2009 5:09 AM
Subscribe
What books would you recommend for embedded C programming?
I'm involved in new group project (University) that will eventually evolve into an autonomous path-finding robot. FYI, it will probably use a PIC32 processor.
I have a background in programming, and a good (practical) understanding of Java and C# having used them a lot over the last four years. However, pure C is not my strongest point, and I'm needing a good brush-up! I've done a bit as part of a module a while back, but certainly not enough to dive into detailed algorithms.
What good books (or online resources) would you recommend to someone who has a reasonable set of experience with programming in general but needs a bit more to read on pure C?
posted by gkhewitt to computers & internet (6 comments total)
2 users marked this as a favorite
Embedded ("non-hosted") means you don't have the standard library, and that you don't get a program loaded (you just jump to an instruction) so you don't have main(), anything that happens before main (code relocation), or anything that happens after main (atexit, etc.).And you may not have dynamic memory allocation (malloc, etc.).
What you'll probably find is that some portion the the standard libs will be ported into the project, just because: everyone knows them, everyone uses them, and there are good public domain/BSD licensed implementations of them.
Probably the hardest thing to get your head around will be no dynamic memory; basically you'll either have to put together your own malloc, or get used to using static structures exclusively. For that (well, actually for either case), it's very useful to know that the C Standard guarantees that pointer to struct can be portably converted to a pointer to the first element of the struct and back. It's also important to know that the Standard makes few guarantees about alignment and padding, so you'll have consult you compiler's documentation for your target architecture to get this right (and right a bunch of cryptic headers to achieve it).
You may find perusing the Rockbox source code to be informative; that's embedded code that runs more-or-less portably (with lotsof header hacks) on numerous different architectures.
posted by orthogonality at 5:37 AM on February 11