Is interpreted according to the normal rules for a

Info icon This preview shows pages 48–50. Sign up to view the full content.

is interpreted according to the normal rules for a string constant: backslash escapes are interpreted. This is different from ‘ #include ’. Previous versions of CPP did not interpret escapes in ‘ #line ’; we have changed it because the standard requires they be interpreted, and most other compilers do. #line anything else anything else is checked for macro calls, which are expanded. The result should match one of the above two forms. #line ’ directives alter the results of the __FILE__ and __LINE__ predefined macros from that point on. See Section 3.7.1 [Standard Predefined Macros], page 21 . They do not have any effect on ‘ #include ’’s idea of the directory containing the current file. This is a change from GCC 2.95. Previously, a file reading
Image of page 48

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

Chapter 7: Pragmas 45 #line 1 "../src/gram.y" #include "gram.h" would search for ‘ gram.h ’ in ‘ ../src ’, then the ‘ -I ’ chain; the directory containing the physical source file would not be searched. In GCC 3.0 and later, the ‘ #include ’ is not affected by the presence of a ‘ #line ’ referring to a different directory. We made this change because the old behavior caused problems when generated source files were transported between machines. For instance, it is common practice to ship gen- erated parsers with a source release, so that people building the distribution do not need to have yacc or Bison installed. These files frequently have ‘ #line ’ directives referring to the directory tree of the system where the distribution was created. If GCC tries to search for headers in those directories, the build is likely to fail. The new behavior can cause failures too, if the generated file is not in the same directory as its source and it attempts to include a header which would be visible searching from the directory containing the source file. However, this problem is easily solved with an additional -I ’ switch on the command line. The failures caused by the old semantics could sometimes be corrected only by editing the generated files, which is difficult and error-prone. 7 Pragmas The ‘ #pragma ’ directive is the method specified by the C standard for providing additional information to the compiler, beyond what is conveyed in the language itself. Three forms of this directive (commonly known as pragmas ) are specified by the 1999 C standard. A C compiler is free to attach any meaning it likes to other pragmas. GCC has historically preferred to use extensions to the syntax of the language, such as __attribute__ , for this purpose. However, GCC does define a few pragmas of its own. These mostly have effects on the entire translation unit or source file. In GCC version 3, all GNU-defined, supported pragmas have been given a GCC prefix. This is in line with the STDC prefix on all pragmas defined by C99. For backward com- patibility, pragmas which were recognized by previous versions are still recognized without the GCC prefix, but that usage is deprecated. Some older pragmas are deprecated in their entirety. They are not recognized with the GCC prefix. See Section 11.3 [Obsolete Features],
Image of page 49
Image of page 50
This is the end of the preview. Sign up to access the rest of the document.
  • Summer '13
  • Noone
  • GCC, C preprocessor

{[ 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