Transcription of The GNU C Reference Manual
1 The GNU C Reference ManualTrevis RothwellJames YoungmanCopyrightc 2007-2015 Free Software Foundation, is granted to copy, distribute and/or modify this document under the terms ofthe GNU Free Documentation License, Version or any later version published by theFree Software Foundation; with no Invariant Sections, with no Front-Cover Texts and noBack-Cover Texts. A copy of the license is included in the section entitled GNU FreeDocumentation License. iTable of ..11 Lexical Identifiers.. Keywords.. Constants.. Integer Constants.. character Constants.. Real Number Constants.. String Constants.. Operators.. Separators.
2 White Space..62 Data Primitive Data Types.. Integer Types.. Real Number Types.. Complex Number Types.. Standard Complex Number Types.. GNU Extensions for Complex Number Types.. Enumerations.. Defining Enumerations.. Declaring Enumerations.. Unions.. Defining Unions.. Declaring Union Variables.. Declaring Union Variables at Definition.. Declaring Union Variables After Definition.. Initializing Union Members.. Accessing Union Members.. Size of Unions.. Structures.. Defining Structures.. Declaring Structure Variables.. Declaring Structure Variables at Definition.. Declaring Structure Variables After Definition.
3 Initializing Structure Members.. Accessing Structure Members.. Bit Fields.. Size of Structures.. Arrays.. Declaring Arrays.. Initializing Arrays.. Accessing Array Elements.. Multidimensional Arrays.. Arrays as Strings.. Arrays of Unions.. Arrays of Structures.. Pointers.. Declaring Pointers.. Initializing Pointers.. Pointers to Unions.. Pointers to Structures.. Incomplete Types.. Type Qualifiers.. Storage Class Specifiers.. Renaming Types..273 Expressions and Expressions.. Assignment Operators.. Incrementing and Decrementing.. Arithmetic Operators.. Complex Conjugation.
4 Comparison Operators.. Logical Operators.. Bit Shifting.. Bitwise Logical Operators.. Pointer Operators.. The sizeof Operator.. Type Casts.. Array Subscripts.. Function Calls as Expressions.. The Comma Operator.. Member Access Expressions.. Conditional Expressions.. Statements and Declarations in Expressions.. Operator Precedence.. Order of Evaluation.. Side Effects.. Sequence Points.. Sequence Points Constrain Expressions.. Sequence Points and Signal Delivery..44iii4 Labels.. Expression Statements.. TheifStatement.. TheswitchStatement.. ThewhileStatement.. ThedoStatement.
5 TheforStatement.. Blocks.. The Null Statement.. ThegotoStatement.. ThebreakStatement.. ThecontinueStatement.. ThereturnStatement.. ThetypedefStatement..545 Function Declarations.. Function Definitions.. Calling Functions.. Function Parameters.. Variable Length Parameter Lists.. Calling Functions Through Function Pointers.. ThemainFunction.. Recursive Functions.. Static Functions.. Nested Functions..636 Program Structure and Program Structure.. Scope..647 A Sample ..69 Appendix Basics of Integer Overflow.. Examples of Code Assuming Wraparound Overflow.. Optimizations That Break Wraparound Arithmetic.
6 Practical Advice for Signed Overflow Issues.. Signed Integer Division and Integer Overflow..75 GNU Free Documentation is a Reference Manual for the C programming language as implemented by the GNUC ompiler Collection (GCC). Specifically, this Manual aims to document: The 1989 ANSI C standard, commonly known as C89 The 1999 ISO C standard, commonly known as C99 , to the extent that C99 isimplemented by GCC The current state of GNU extensions to standard CThis Manual describes C89 as its baseline. C99 features and GNU extensions are explicitlylabeled as default, GCC will compile code as C89 plus GNU-specific extensions. Much of C99is supported; once full support is available, the default compilation dialect will be C99plus GNU-specific extensions.
7 (Some of the GNU extensions to C89 ended up, sometimesslightly modified, as standard language features in C99.)The C language includes a set of preprocessor directives, which are used for thingssuch as macro text replacement, conditional compilation, and file inclusion. Althoughnormally described in a C language Manual , the GNU C preprocessor has been thoroughlydocumented inThe C Preprocessor, a separate Manual which covers preprocessing for C,C++, and Objective-C programs, so it is not included to everyone who has helped with editing, proofreading, ideas, typesetting, andadministrivia, including: Diego Andres Alvarez Marin, Nelson H.
8 F. Beebe, Karl Berry,Robert Chassell, Hanfeng Chen, Mark de Volld, Antonio Diaz Diaz, dine, Andreas Foerster,Denver Gingerich, Lisa Goldstein, Robert Hansen, Jean-Christophe Helary, Mogens Het-sholm, Teddy Hogeborn, Joe Humphries, J. Wren Hunt, Dutch Ingraham, Adam Johansen,Vladimir Kadlec, Benjamin Kagia, Dright Kayorent, Sugun Kedambadi, Felix Lee, BjornLiencres, Steve Morningthunder, Aljosha Papsch, Matthew Plant, Jonathan Sisti, RichardStallman, J. Otto Tennant, Ole Tetlie, Keith Thompson, Torrey, James Youngman,and Steve Zachar. Trevis Rothwell serves as project maintainer and, along with JamesYoungman, wrote the bulk of the example programs are based on algorithms in Donald Knuth sThe Art of Com-puter send bug reports and suggestions 1: Lexical Elements21 Lexical ElementsThis chapter describes the lexical elements that make up C source code after elements are calledtokens.
9 There are five types of tokens: keywords, identifiers,constants, operators, and separators. White space, sometimes required to separate tokens,is also described in this IdentifiersIdentifiers are sequences of characters used for naming variables, functions, new data types,and preprocessor macros. You can include letters, decimal digits, and the underscore char-acter _ in first character of an identifier cannot be a letters and uppercase letters are distinct, such thatfooandFOOare twodifferent using GNU extensions, you can also include the dollar sign character $ in KeywordsKeywords are special identifiers reserved for use as part of the programming language cannot use them for any other is a list of keywords recognized by ANSI C89.
10 Auto break case char const continue default do double else enum externfloat for goto if int long register return short signed sizeof staticstruct switch typedef union unsigned void volatile whileISO C99 adds the following keywords:inline _Bool _Complex _Imaginaryand GNU extensions add these keywords:__FUNCTION__ __PRETTY_FUNCTION__ __alignof __alignof__ __asm__asm__ __attribute __attribute__ __builtin_offsetof __builtin_va_arg__complex __complex__ __const __extension__ __func__ __imag __imag____inline __inline__ __label__ __null __real __real____restrict __restrict__ __signed __signed__ __thread __typeof__volatile __volatile__In both ISO C99 and C89 with GNU extensions, the following is also recognized as ConstantsA constant is a literal numeric or character value, such as5or m.