流利的C語言(影印版)
出版時間:2023年03月
頁數(shù):281
“滿滿的實例,本書是一份不可多得的資料,可以讓你的代碼更加簡潔,更易于維護。”
——David Griffiths
Head First C作者
“本書將帶領(lǐng)新手步入打造工業(yè)級C程序的行列?!?br />
——Robert Hanmer
軟件架構(gòu)師
關(guān)于C語言編程的專家建議很難找到。雖然面向?qū)ο缶幊陶Z言的參考幫助有很多,但針對C語言的同類信息卻少得令人吃驚。通過這本實踐指南,初學者和有經(jīng)驗的C語言程序員都能找到相關(guān)的設(shè)計決策指導,包括在構(gòu)建大型程序時如何將它們循序漸進地應用于現(xiàn)役代碼。
作為設(shè)計模式社區(qū)的主要成員,Christopher Preschern解答了如何構(gòu)造C程序、應對錯誤處理、設(shè)計柔性接口等問題。無論你是在尋找特定的模式,還是想了解特定主題的設(shè)計選擇,本書都能助你一臂之力。在第一部分中,你將學習如何實現(xiàn)專門針對C編程語言的實用設(shè)計知識。
第二部分包括應用C編程模式實現(xiàn)大型程序。你將從中學習到模式是如何通過良好的設(shè)計決策提高工作效率的。本書包括以下模式:
● 錯誤處理
● 返回錯誤信息
● 內(nèi)存管理
● 從C函數(shù)返回數(shù)據(jù)
● 數(shù)據(jù)生命周期和所有權(quán)
● 柔性API
● 柔性迭代器接口
● 在模塊化程序中組織文件
● 擺脫#ifdel地獄
- Preface
- Part I. C Patterns
- 1. Error Handling
- Running Example
- Function Split
- Guard Clause
- Samurai Principle
- Goto Error Handling
- Cleanup Record
- Object-Based Error Handling
- Summary
- Further Reading
- Outlook
- 2. Returning Error Information
- Running Example
- Return Status Codes
- Return Relevant Errors
- Special Return Values
- Log Errors
- Summary
- Further Reading
- Outlook
- 3. Memory Management
- Data Storage and Problems with Dynamic Memory
- Running Example
- Stack First
- Eternal Memory
- Lazy Cleanup
- Dedicated Ownership
- Allocation Wrapper
- Pointer Check
- Memory Pool
- Summary
- Further Reading
- Outlook
- 4. Returning Data from C Functions
- Running Example
- Return Value
- Out-Parameters
- Aggregate Instance
- Immutable Instance
- Caller-Owned Buffer
- Callee Allocates
- Summary
- Outlook
- 5. Data Lifetime and Ownership
- Stateless Software-Module
- Software-Module with Global State
- Caller-Owned Instance
- Shared Instance
- Summary
- Further Reading
- Outlook
- 6. Flexible APIs
- Header Files
- Handle
- Dynamic Interface
- Function Control
- Summary
- Further Reading
- Outlook
- 7. Flexible Iterator Interfaces
- Running Example
- Index Access
- Cursor Iterator
- Callback Iterator
- Summary
- Further Reading
- Outlook
- 8. Organizing Files in Modular Programs
- Running Example
- Include Guard
- Software-Module Directories
- Global Include Directory
- Self-Contained Component
- API Copy
- Summary
- Outlook
- 9. Escaping #ifdef Hell
- Running Example
- Avoid Variants
- Isolated Primitives
- Atomic Primitives
- Abstraction Layer
- Split Variant Implementations
- Summary
- Further Reading
- Outlook
- Part II. Pattern Stories
- 10. Implementing Logging Functionality
- The Pattern Story
- Summary
- 11. Building a User Management System
- The Pattern Story
- Summary
- 12. Conclusion
- What You’ve Learned
- Further Reading
- Closing Remarks
- Index
書名:流利的C語言(影印版)
國內(nèi)出版社:東南大學出版社
出版時間:2023年03月
頁數(shù):281
書號:978-7-5766-0562-4
原版書書名:Fluent C
原版書出版商:O'Reilly Media
Christopher Preschern
Christopher Preschern組織了設(shè)計模式會議并發(fā)起了改進模式編寫的倡議。作為ABB公司的C程序員,他收集并記錄了如何編寫工業(yè)級代碼的實踐知識。他曾在格拉茨科技大學講授編碼以及代碼質(zhì)量的相關(guān)課程,擁有計算機科學博士學位。
The animal on the cover of Fluent C is a Major Mitchell’s cockatoo (Lophochroa leadbeateri), also known as Leadbeater’s cockatoo or the pink cockatoo. This mediumsized cockatoo is named after Major Thomas Mitchell, a surveyor and explorer of southeastern Australia. It is native to the arid and semi-arid parts of Australia, preferring wooded areas where it can forage for seeds. Its plumage is primarily white and a pale salmon pink, with deeper pink under its wings and a bright red, yellow, and white crest. Males and females look almost identical, though males are usually a little larger and have brown eyes, while females have reddish-pink eyes and broader yellow stripes in their crests.
Major Mitchell’s cockatoos are popular as pets, though they are very social birds that require a great deal of attention from their owners. In the wild, they nest in pairs and require large territories, making their habitats vulnerable to fragmentation. Although they are considered a species of least concern, their numbers have declined as woodlands have been cleared. They are also threatened by illegal trapping for the pet trade.