DOC HOME
SITE MAP
MAN PAGES
GNU INFO
SEARCH
PRINT BOOK
Programming in standard C and C++
Introduction to programming in standard C and C++
Summary of contents
Creating an executable
Advanced programming utilities
Program analysis
C and C++ compilation
C language
Modular programming in C
C++ language
Libraries and header files
How C and C++ programs communicate with the shell
Other tools
C and C++ compilation system
Compiling and linking
Components of the C compilation system
C preprocessor
C compiler
C assembler
C linker
Organization of the C compilation system
Components of the C++ compilation system
C++ preprocessor
C++ compiler
C++ assembler
C++ prelinker
C++ linker
C++ name filter
Organization of the C++ compilation system
Basic cc and CC command line syntax
hello world program
Creating the executable
Executing the program
Specifying a different executable name
Invoking the preprocessor only
Invoking the preprocessor and compiler only
Suppressing the linker phase
Passing files to cc and CC
Compiling multiple source files
A note on command line options
Commonly used command line options
Searching for a header file
Preparing your program for debugging
Preparing your program for profiling
Optimizing your program
Software administration
Link editing
Static linking
Dynamic linking
Default arrangement
Linking with standard libraries
Turning off dynamic linking
Linking with other standard libraries
Creating and linking with archive libraries
Creating and linking with C shared object libraries
Naming your shared object
Linking a shared object with another library
Specifying directories to be searched by the link editor
Specifying directories to be searched by the dynamic linker
Implementation
Handling multiply defined symbols
Checking for run-time compatibility
Dynamic linking programming interface
Guidelines for building shared objects
Minimize the library's data segment.
Minimize paging activity.
Library maintenance
C++ and dynamic linking
Building a C++ shared object
Static constructors and destructors
Diagnostics from the dynamic linker
C++ external function name encoding
Accessing C functions from C++
Quick-reference guide
Libraries and header files
Header files
C++ precompiled headers
Automatic precompiled header processing
Manual precompiled header processing
Other ways to control precompiled headers
Performance issues
How to use library functions
C library (libc)
Subsection 3S routines
Subsection 3C routines
System calls
Math library (libm)
General purpose library (libgen)
Standard I/O
Standard files
Named files
Passing command line arguments
Reentrant libraries
BSD system libraries and header files
Accessing BSD libraries and header files
C language compilers
Compilation modes
Feature test macros
Global behavior
Phases of translation
Source files and tokenization
Tokens
Identifiers
Keywords
Constants
Integral constants
Floating point constants
Character constants
Wide characters and multibyte characters
String literals
Wide string literals
Comments
Preprocessing
Trigraph sequences
Preprocessing tokens
Preprocessing numbers
Preprocessing directives
Preprocessing operators
Macro definition and expansion
File inclusion
Conditional compilation
Line control
Assertions
Version control
Pragmas
Error generation
Predefined names
Declarations and definitions
Basic types
Type qualifiers
Structures and unions
Enumerations
Scope
Storage duration
Storage class specifiers
Declarators
Pointer declarators
Array declarators
Function declarators
Function definitions
Conversions and expressions
Implicit conversions
Characters and integers
Signed and unsigned integers
Integral and floating
Float and double
Usual arithmetic conversions
Expressions
Objects and lvalues
Primary expressions
Operators
Unary operators
Cast operators - explicit conversions
Multiplicative operators
Additive operators
Bitwise shift operators
Relational operators
Equality operators
Bitwise AND operator
Bitwise exclusive OR operator
Bitwise OR operator
Logical AND operator
Logical OR operator
Conditional operator
Assignment expressions
Comma operator
Structure operators
Associativity and precedence of operators
Constant expressions
Initialization
Statements
Expression statement
Compound statement
Selection statements
if
else
switch
Iteration statements
while
do-while
for
Jump statements
goto
break
continue
return
Portability considerations
Complying with standard C
Mixing old and new style functions
Writing new code
Updating existing code
Mixing considerations
Examples
Functions with varying arguments
Example
Promotions: unsigned vs. value preserving
Background
Compilation behavior
First example: using a cast
Bit-fields
Second example: result is the same
Integral constants
Third example: integral constants
Tokenization and preprocessing
ANSI C translation phases
Old C translation phases
Logical source lines
Macro replacement
Stringizing
Token pasting
Using const and volatile
Types for lvalues
Type qualifiers in derived types
Using const to read character values
Examples of const usage
When to use volatile
Examples of volatile usage
Multibyte characters and wide characters
``Asianization'' means multibyte characters
Encoding variations
Wide characters
Conversion functions
C language features
Standard headers and reserved names
Balancing process
Standard headers
Names reserved for implementation use
Names reserved for expansion
Names safe to use
Internationalization
Locales
The setlocale function
Changed functions
New functions
Grouping and evaluation in expressions
Definitions
The Kernighan and Ritchie C rearrangement license
The ANSI C rules
Parentheses grouping and evaluation
The ``As If'' rule
Incomplete types
Types
Completing incomplete types
Declarations
Expressions
Justification
Examples
Compatible and composite types
Multiple declarations
Separate compilation compatibility
Single compilation compatibility
Compatible pointer types
Compatible array types
Compatible function types
Special cases
Composite type
C++ language
Compilation modes
C++ dialect accepted
Normal C++ mode
Extensions accepted in normal C++ mode
Anachronisms accepted
Extensions accepted in cfront transition mode
Instantiating C++ templates
The instantiation problem
Coding standards for template definitions
Manual instantiation
Pragma interface
Instantiation via the command line
Single files
Automatic instantiation
Dependency management
Performance
What can go wrong
Other considerations
Inlines
Specializations
Libraries
More on linking template code into archives
The one instantiation per object scheme
Special symbols
Using C++ exception handling
Performance implications
Mixed language programming
Other implementation dependencies
Compiler diagnostics
C compiler diagnostics
Message types and applicable options
Operator names in messages
Messages
Other error messages
C++ compiler diagnostics
Object files
File format
Data representation
ELF header
ELF identification
Sections
Rules for linking unrecognized sections
Special sections
String table
Symbol table
Symbol values
Relocation
Program header
Base address
Segment permissions
Segment contents
Note section
Program loading (Processor specific)
Dynamic linking
Program interpreter
Dynamic linker
Dynamic section
Shared object dependencies
Substitution sequences
Global offset table
Procedure linkage table
Hash table
Initialization and termination functions
Floating point operations
IEEE arithmetic
Data types and formats
Single-precision
Double-precision
Extended-precision
Normalized numbers
Denormalized numbers
Maximum and minimum representable floating point values
Special-case values
NaNs and infinities
Rounding control
Exceptions, sticky bits, and trap bits
Single-precision floating point operations
Double-extended-precision
IEEE requirements
Conversion of floating point formats to integer
Square root
Compares and unordered condition
Analyzing your code with lint
Why lint is an important tool
Options and directives
lint and the compiler
Message formats
What lint does
Consistency checks
Portability checks
Suspicious constructs
Usage
lint libraries
lint filters
Options and directives listed
lint-specific messages
m4 macro processor
Defining macros
Quoting
Arguments
Arithmetic built-ins
File inclusion
Diversions
System command
Conditionals
String manipulation
Printing
Linking with the mapfile option
Using the mapfile option
Mapfile structure and syntax
Segment declarations
Mapping directives
Size-symbol declarations
Mapping example
Mapfile option defaults
Internal map structure
Error messages
Warnings
Fatal errors
Enhanced asm facility
Definition of terms
Example
Definition
Use
Using asm macros
Definition
Storage modes
asm body
Writing asm macros