The c standard requires that all system specific

Info icon This preview shows pages 36–38. Sign up to view the full content.

View Full Document Right Arrow Icon
The C standard requires that all system-specific macros be part of the reserved names- pace . All names which begin with two underscores, or an underscore and a capital letter, are reserved for the compiler and library to use as they wish. However, historically system- specific macros have had names with no special prefix; for instance, it is common to find unix defined on Unix systems. For all such macros, GCC provides a parallel macro with two underscores added at the beginning and the end. If unix is defined, __unix__ will be defined too. There will never be more than two underscores; the parallel of _mips is __mips__ . When the ‘ -ansi ’ option, or any ‘ -std ’ option that requests strict conformance, is given to the compiler, all the system-specific predefined macros outside the reserved namespace are suppressed. The parallel macros, inside the reserved namespace, remain defined. We are slowly phasing out all predefined macros which are outside the reserved names- pace. You should never use them in new programs, and we encourage you to correct older code to use the parallel macros whenever you find it. We don’t recommend you use the system-specific macros that are in the reserved namespace, either. It is better in the long run to check specifically for features you need, using a tool such as autoconf . 3.7.4 C ++ Named Operators In C ++ , there are eleven keywords which are simply alternate spellings of operators normally written with punctuation. These keywords are treated as such even in the preprocessor. They function as operators in ‘ #if ’, and they cannot be defined as macros or poisoned. In C, you can request that those keywords take their C ++ meaning by including ‘ iso646.h ’. That header defines each one as a normal object-like macro expanding to the appropriate punctuator. These are the named operators and their corresponding punctuators: Named Operator Punctuator and && and_eq &= bitand & bitor | compl ~ not ! not_eq != or || or_eq |= xor ^ xor_eq ^= 3.8 Undefining and Redefining Macros If a macro ceases to be useful, it may be undefined with the ‘ #undef ’ directive. ‘ #undef takes a single argument, the name of the macro to undefine. You use the bare macro name, even if the macro is function-like. It is an error if anything appears on the line after the macro name. ‘ #undef ’ has no effect if the name is not a macro.
Image of page 36

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

View Full Document Right Arrow Icon
Chapter 3: Macros 33 #define FOO 4 x = FOO; 7→ x = 4; #undef FOO x = FOO; 7→ x = FOO; Once a macro has been undefined, that identifier may be redefined as a macro by a subsequent ‘ #define ’ directive. The new definition need not have any resemblance to the old definition. However, if an identifier which is currently a macro is redefined, then the new definition must be effectively the same as the old one. Two macro definitions are effectively the same if: Both are the same type of macro (object- or function-like).
Image of page 37
Image of page 38
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