
Fluent C
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Expert advice on C programming is hard to find. While much help is available for object-oriented programming languages, there''s surprisingly little for the C language. With this hands-on guide, beginners and experienced C programmers alike will find guidance about design decisions, including how to apply them bit by bit to running code examples when building large-scale programs.
Christopher Preschern, a leading member of the design patterns community, answers questions such as how to structure C programs, cope with error handling, or design flexible interfaces. Whether you''re looking for one particular pattern or an overview of design options for a specific topic, this book shows you how to implement hands-on design knowledge specifically for the C programming language.
You''ll find design patterns for:
- Error handling
- Returning error information
- Memory management
- Returning data from C functions
- Data lifetime and ownership
- Flexible APIs
- Flexible iterator interfaces
- Organizing files in modular programs
- Escaping #ifdef Hell
More details
Other editions
Additional editions

Content
- Cover
- Copyright
- Table of Contents
- Preface
- Why I Wrote This Book
- Patterns Basics
- How to Read This Book
- Overview of the Patterns
- Conventions Used in This Book
- Using Code Examples
- O'Reilly Online Learning
- How to Contact Us
- Acknowledgments
- Part I. C Patterns
- Chapter 1. Error Handling
- Running Example
- Function Split
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Guard Clause
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Samurai Principle
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Goto Error Handling
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Cleanup Record
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Object-Based Error Handling
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Chapter 2. Returning Error Information
- Running Example
- Return Status Codes
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Return Relevant Errors
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Special Return Values
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Log Errors
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Chapter 3. Memory Management
- Data Storage and Problems with Dynamic Memory
- Running Example
- Stack First
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Eternal Memory
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Lazy Cleanup
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Dedicated Ownership
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Allocation Wrapper
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Pointer Check
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Memory Pool
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Chapter 4. Returning Data from C Functions
- Running Example
- Return Value
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Out-Parameters
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Aggregate Instance
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Immutable Instance
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Caller-Owned Buffer
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Callee Allocates
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Outlook
- Chapter 5. Data Lifetime and Ownership
- Stateless Software-Module
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Software-Module with Global State
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Caller-Owned Instance
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Shared Instance
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Chapter 6. Flexible APIs
- Header Files
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Handle
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Dynamic Interface
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Function Control
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Chapter 7. Flexible Iterator Interfaces
- Running Example
- Index Access
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Cursor Iterator
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Callback Iterator
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Chapter 8. Organizing Files in Modular Programs
- Running Example
- Include Guard
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Software-Module Directories
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Global Include Directory
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Self-Contained Component
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- API Copy
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Outlook
- Chapter 9. Escaping #ifdef Hell
- Running Example
- Avoid Variants
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Isolated Primitives
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Atomic Primitives
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Abstraction Layer
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Split Variant Implementations
- Context
- Problem
- Solution
- Consequences
- Known Uses
- Applied to Running Example
- Summary
- Further Reading
- Outlook
- Part II. Pattern Stories
- Chapter 10. Implementing Logging Functionality
- The Pattern Story
- File Organization
- Central Logging Function
- Logging Source Filter
- Conditional Logging
- Multiple Logging Destinations
- File Logging
- Cross-Platform Files
- Using the Logger
- Summary
- Chapter 11. Building a User Management System
- The Pattern Story
- Data Organization
- File Organization
- Authentication: Error Handling
- Authentication: Error Logging
- Adding Users: Error Handling
- Iterating
- Using the User Management System
- Summary
- Chapter 12. Conclusion
- What You've Learned
- Further Reading
- Closing Remarks
- Index
- About the Author
- Colophon
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.