Skip to Content
Smaller C
book

Smaller C

by Marc Loy
May 2021
Intermediate to advanced
311 pages
7h 45m
English
O'Reilly Media, Inc.
Content preview from Smaller C

Chapter 7. Libraries

One of C’s best qualities is the minimal adornment present in its compiled code. A favorite snipe at some more modern languages like Java is the size of the “Hello, World” program. Our very first program back in “Creating a C ‘Hello, World’” takes up a little over 16Kb on my Linux machine without any optimizations. Achieving the same output from a standalone executable on the same system using Java, though, requires tens of megabytes and much, much more effort to build. That’s not an entirely fair comparison since the Java hello application needs the entire Java runtime baked into the executable, but that’s also the point: C makes it easy to create lean code for a given system.

That ease is great when we’re tackling small things like “Hello, World” or even most of the examples from past chapters. But as we get ready to jump into the world of microcontrollers and Arduino, we’re left worrying about re-creating our own solutions to some pretty mundane problems. For example, we’ve written some of our own functions to compare strings. We wrote a fancier program to encode base64 content. That stuff is fun, but do we always have to do this type of work from scratch?

Happily, the answer to that question is: no. C supports the notion of using a library for quick, friendly expansion of its capabilities—without losing its lean profile for the final executable. A library is a bundle of code that can be imported into your projects to add new capabilities, like working ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Extreme C

Extreme C

Kamran Amini
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
Programming C# 10

Programming C# 10

Ian Griffiths
C in a Nutshell, 2nd Edition

C in a Nutshell, 2nd Edition

Peter Prinz, Tony Crawford

Publisher Resources

ISBN: 9781098100322Errata Page