Effective C: An Introduction to Professional C Programming. 2 Ed

Effective C: An Introduction to Professional C Programming. 2 Ed

Effective C: An Introduction to Professional C Programming. 2 Ed
Автор: Seacord Robert C.
Дата выхода: 2025
Издательство: No Starch Press, Inc.
Количество страниц: 314
Размер файла: 4.9 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Cover....1

Praise for Effective C....3

Title Page....5

Copyright....6

Dedication....7

About the Author....9

About the Contributor....9

About the Technical Reviewer to the First Edition....9

About the Technical Reviewer to the Second Edition....10

Brief Contents....11

Contents in Detail....13

Foreword to the Second Edition....19

Foreword to the First Edition....21

Acknowledgments....23

Introduction....25

A Brief History of C....26

The C Standard....27

The CERT C Coding Standard....28

Common Weakness Enumeration....28

Who This Book Is For....28

What’s in This Book....29

1. Getting Started With C....31

Developing Your First C Program....31

Compiling and Running a Program....33

Function Return Values....34

Formatted Output....35

Editors and Integrated Development Environments....36

Compilers....37

GNU Compiler Collection....38

Clang....38

Microsoft Visual Studio....38

Portability....39

Implementation-Defined Behavior....39

Unspecified Behavior....40

Undefined Behavior....40

Locale-Specific Behavior and Common Extensions....41

Summary....41

2. Objects, Functions, and Types....43

Entities....43

Declaring Variables....44

Swapping Values, First Attempt....45

Swapping Values, Second Attempt....46

Object Types....48

Boolean....48

Character....49

Arithmetic....49

void....52

Derived Types....52

Function....52

Pointer....53

Array....55

Structure....57

Union....58

Tags....59

Type Qualifiers....61

const....61

volatile....62

restrict....63

Scope....64

Storage Duration....65

Storage Class....66

static....66

extern....67

thread_local....67

constexpr....67

register....68

typedef....68

auto....68

typeof Operators....69

Alignment....70

Variably Modified Types....72

Attributes....73

Summary....75

3. Arithmetic Types....77

Integers....78

Padding, Width, and Precision....78

Integer Ranges....78

Integer Declarations....79

Unsigned Integers....79

Signed Integers....82

Bit-Precise Integer Types....86

Integer Constants....87

Floating-Point Representation....89

Floating Types and Encodings....89

C Floating-Point Model....90

Floating-Point Arithmetic....92

Floating-Point Values....92

Floating Constants....94

Arithmetic Conversion....94

Integer Conversion Rank....95

Integer Promotions....96

Usual Arithmetic Conversions....97

An Example of Implicit Conversion....99

Safe Conversions....100

Summary....102

4. Expressions and Operators....103

Simple Assignment....104

Evaluations....105

Function Invocation....106

Increment and Decrement Operators....107

Operator Precedence and Associativity....108

Order of Evaluation....110

Unsequenced and Indeterminately Sequenced Evaluations....111

Sequence Points....111

sizeof Operator....112

Arithmetic Operators....113

Unary + and –....113

Logical Negation....113

Additive....113

Multiplicative....114

Bitwise Operators....115

Complement....115

Shift....116

Bitwise AND....117

Bitwise Exclusive OR....118

Bitwise Inclusive OR....118

Logical Operators....119

Cast Operators....120

Conditional Operator....121

alignof Operator....122

Relational Operators....122

Compound Assignment Operators....123

Comma Operator....123

Pointer Arithmetic....124

Summary....126

5. Control Flow....127

Expression Statements....127

Compound Statements....128

Selection Statements....129

if....129

switch....132

Iteration Statements....135

while....135

do...while....136

for....137

Jump Statements....139

goto....139

continue....141

break....141

return....142

Summary....143

6. Dynamically Allocated Memory....145

Storage Duration....146

The Heap and Memory Managers....146

When to Use Dynamically Allocated Memory....147

Memory Management....147

malloc....148

aligned_alloc....150

calloc....150

realloc....151

reallocarray....153

free....153

free_sized....154

free_aligned_sized....154

Memory States....156

Flexible Array Members....157

Other Dynamically Allocated Storage....158

alloca....158

Variable-Length Arrays....159

Debugging Allocated Storage Problems....162

dmalloc....162

Safety-Critical Systems....164

Summary....165

7. Characters and Strings....167

Characters....168

ASCII....168

Unicode....168

Source and Execution Character Sets....170

Data Types....170

Character Constants....172

Escape Sequences....173

Linux....174

Windows....175

Character Conversion....176

Strings....179

String Literals....180

String-Handling Functions....182

and ....182

Annex K Bounds-Checking Interfaces....191

POSIX....194

Microsoft....195

Summary....195

8. Input/Output....197

Standard I/O Streams....198

Error and End-of-File Indicators....198

Stream Buffering....199

Predefined Streams....200

Stream Orientation....201

Text and Binary Streams....202

Opening and Creating Files....202

fopen....202

open....204

Closing Files....206

fclose....206

close....207

Reading and Writing Characters and Lines....207

Stream Flushing....210

Setting the Position in a File....210

Removing and Renaming Files....213

Using Temporary Files....214

Reading Formatted Text Streams....214

Reading from and Writing to Binary Streams....218

Endian....221

Summary....222

9. Preprocessor....225

The Compilation Process....226

File Inclusion....227

Conditional Inclusion....228

Generating Diagnostics....230

Using Header Guards....231

Macro Definitions....232

Macro Replacement....235

Type-Generic Macros....237

Embedded Binary Resources....239

Predefined Macros....240

Summary....241

10. Program Structure....243

Principles of Componentization....243

Coupling and Cohesion....244

Code Reuse....245

Data Abstractions....245

Opaque Types....247

Executables....248

Linkage....249

Structuring a Simple Program....251

Building the Code....255

Summary....257

11. Debugging, Testing, and Analysis....259

Assertions....259

Static Assertions....260

Runtime Assertions....262

Compiler Settings and Flags....263

GCC and Clang Flags....265

GCC and Clang Flags....265

Debugging....271

Unit Testing....275

Static Analysis....280

Dynamic Analysis....282

AddressSanitizer....283

Running the Tests....284

Instrumenting the Code....284

Running the Instrumented Tests....285

Summary....287

Future Directions....287

Appendix: The Fifth Edition of the C Standard (C23)....289

Attributes....289

Keywords....290

Integer Constant Expressions....290

Enumeration Types....291

Type Inference....291

typeof Operators....292

K&R C Functions....292

Preprocessor....292

Integer Types and Representations....293

unreachable Function-Like Macro....294

Bit and Byte Utilities....294

IEEE Floating-Point Support....295

References....297

Index....301

Back Cover....314

Effective C, 2nd edition, is an introduction to essential C language programming that will soon have you writing programs, solving problems, and building working systems.

The latest release of the C programming language, C23, enhances the safety, security, and usability of the language. This second edition of Effective C has been thoroughly updated to cover C23, offering a modern introduction to C that will teach you best practices for writing professional, effective, and secure programs that solve real-world problems.

Effective C is a true product of the C community. Robert C. Seacord, a long-standing member of the C standards committee with over 40 years of programming experience, developed the book in collaboration with other C experts, such as Clang’s lead maintainer Aaron Ballman and C project editor JeanHeyd Meneide. Thanks to the efforts of this expert group, you’ll learn how to:

  • Develop professional C code that is fast, robust, and secure
  • Use objects, functions, and types effectively
  • Safely and correctly use integers and floating-point types
  • Manage dynamic memory allocation
  • Use strings and character types efficiently
  • Perform I/O operations using C standard streams and POSIX file descriptors
  • Make effective use of C’s preprocessor
  • Debug, test, and analyze C programs

The world runs on code written in C. Effective C will show you how to get the most out of the language and build robust programs that stand the test of time.

New to this edition: This edition has been extensively rewritten to align with modern C23 programming practices and leverage the latest C23 features.

Updated to cover C23


Похожее:

Список отзывов:

Нет отзывов к книге.