Programming with GNU Software
Total Page:16
File Type:pdf, Size:1020Kb
1 Programming with GNU Software Edition 2, 4 September 2002 $Id: gnuprog2.texi,v 1.22 2002/08/15 19:41:25 rmeeking Exp $ 2 Programming with GNU Software Copyright c 2000, 2001 Gary V. Vaughan, Akim Demaille, Paul Scott, Bruce Korb, Richard Meeking Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". i Table of Contents Foreword . 1 1 Introduction . 3 1.1 what this book is . 3 1.2 What the gde is not. 3 1.3 Audience . 4 1.4 this book's organization. 4 1.5 What You Are Presumed to Know . 4 1.6 Conventions Used in This Book. 6 2 The GNU C Library. 7 2.1 Glibc Architecture Overview . 7 2.2 Standards Conformance. 9 2.3 Memory Management. 9 2.3.1 alloca . 9 2.3.2 obstack . 11 2.3.3 argz . 14 2.4 Input and Output . 14 2.4.1 Signals . 14 2.4.2 Time Formats . 17 2.4.3 Formatted Printing . 22 2.5 Error Handling. 22 2.6 Pattern Matching . 24 2.6.1 Wildcard Matching . 24 2.6.2 Filename Matching . 27 2.6.3 Regular Expression Matching . 27 3 libstdc++ and the Standard Template Library . 29 3.1 How the STL is Structured. 29 3.2 Containers and Iterators . 31 3.2.1 Preliminaries . 33 3.2.2 A Crash Course in Iterators . 35 3.2.3 Vector . 37 3.2.4 Deque . 42 3.2.5 List. 44 3.2.6 Set . 46 3.2.7 Multiset . 48 3.2.8 Map . 50 3.2.9 Multimap . 51 3.3 Generic Algorithms and Function Objects . 52 3.3.1 Function Objects - in a Nutshell . 52 3.3.2 Some Prede¯ned Function Objects . 55 3.3.3 Function Adaptors . 55 3.3.4 Introducing Generic Algorithms. 57 3.3.5 for each . 58 3.3.6 ¯nd. 59 3.3.7 transform . 61 ii Programming with GNU Software 3.3.8 partition . 62 3.3.9 accumulate . 63 3.3.10 Other Generic Algorithms . 64 3.4 Strings . 64 3.4.1 Basic String Usage . 64 3.4.2 Iterators and Generic Algorithms . 68 3.5 STL Reference Section . 68 3.5.1 Container Summary . 68 3.5.2 Function Object Summary . 71 3.5.2.1 Standard Function Objects . 71 3.5.2.2 Function Adaptor Reference . 72 3.5.3 Generic Algorithm Summary . 72 3.5.4 String Summary . 72 3.6 Further Reading. 72 4 The GNU Compiler Collection . 75 4.1 An Introduction to GCC . 75 4.1.1 History of GCC. 75 4.1.2 Where to get GCC. 76 4.1.3 A Brief Overview . 76 4.1.3.1 The Broad Picture . 76 4.1.3.2 Front and Back Ends . 77 4.2 GCC Commands . 78 4.2.1 Overview. ..