Line comments are not in the 1989 edition of the c

Info icon This preview shows pages 7–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Line comments are not in the 1989 edition of the C standard, but they are recognized by GCC as an extension. In C ++ and in the 1999 edition of the C standard, they are an official part of the language.
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Chapter 1: Overview 4 Since these transformations happen before all other processing, you can split a line mechanically with backslash-newline anywhere. You can comment out the end of a line. You can continue a line comment onto the next line with backslash-newline. You can even split ‘ /* ’, ‘ */ ’, and ‘ // ’ onto multiple lines with backslash-newline. For example: /\ * */ # /* */ defi\ ne FO\ O 10\ 20 is equivalent to #define FOO 1020 . All these tricks are extremely confusing and should not be used in code intended to be readable. There is no way to prevent a backslash at the end of a line from being interpreted as a backslash-newline. This cannot affect any correct program, however. 1.3 Tokenization After the textual transformations are finished, the input file is converted into a sequence of preprocessing tokens . These mostly correspond to the syntactic tokens used by the C compiler, but there are a few differences. White space separates tokens; it is not itself a token of any kind. Tokens do not have to be separated by white space, but it is often necessary to avoid ambiguities. When faced with a sequence of characters that has more than one possible tokenization, the preprocessor is greedy. It always makes each token, starting from the left, as big as possible before moving on to the next token. For instance, a+++++b is interpreted as a ++ ++ + b , not as a ++ + ++ b , even though the latter tokenization could be part of a valid C program and the former could not. Once the input file is broken into tokens, the token boundaries never change, except when the ‘ ## ’ preprocessing operator is used to paste tokens together. See Section 3.5 [Concatenation], page 18 . For example, #define foo() bar foo()baz 7→ bar baz not 7→ barbaz The compiler does not re-tokenize the preprocessor’s output. Each preprocessing token becomes one compiler token. Preprocessing tokens fall into five broad classes: identifiers, preprocessing numbers, string literals, punctuators, and other. An identifier is the same as an identifier in C: any sequence of letters, digits, or underscores, which begins with a letter or underscore. Keywords of C have no significance to the preprocessor; they are ordinary identifiers. You can define a macro whose name is a keyword, for instance. The only identifier which can be considered a preprocessing keyword is defined . See Section 4.2.3 [Defined], page 42 . This is mostly true of other languages which use the C preprocessor. However, a few of the keywords of C ++ are significant even in the preprocessor. See Section 3.7.4 [C ++ Named Operators], page 32 .
Image of page 8
Chapter 1: Overview 5 In the 1999 C standard, identifiers may contain letters which are not part of the “ba- sic source character set”, at the implementation’s discretion (such as accented Latin let- ters, Greek letters, or Chinese ideograms). This may be done with an extended character set, or the ‘ \u ’ and ‘ \U ’ escape sequences.
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern