Wunused macros warn about macros defined in the main

Info icon This preview shows pages 62–64. Sign up to view the full content.

View Full Document Right Arrow Icon
-Wunused-macros Warn about macros defined in the main file that are unused. A macro is used if it is expanded or tested for existence at least once. The preprocessor will also warn if the macro has not been used at the time it is redefined or undefined. Built-in macros, macros defined on the command line, and macros defined in include files are not warned about. Note: If a macro is actually used, but only used in skipped conditional blocks, then CPP will report it as unused. To avoid the warning in such a case, you might improve the scope of the macro’s definition by, for example, moving it into the first skipped block. Alternatively, you could provide a dummy use with something like: #if defined the_macro_causing_the_warning #endif -Wendif-labels Warn whenever an ‘ #else ’ or an ‘ #endif ’ are followed by text. This usually happens in code of the form #if FOO ... #else FOO ... #endif FOO The second and third FOO should be in comments, but often are not in older programs. This warning is on by default. -Werror Make all warnings into hard errors. Source code which triggers warnings will be rejected. -Wsystem-headers Issue warnings for code in system headers. These are normally unhelpful in finding bugs in your own code, therefore suppressed. If you are responsible for the system library, you may want to see them. -w Suppress all warnings, including those which GNU CPP issues by default. -pedantic Issue all the mandatory diagnostics listed in the C standard. Some of them are left out by default, since they trigger frequently on harmless code. -pedantic-errors Issue all the mandatory diagnostics, and make all mandatory diagnostics into errors. This includes mandatory diagnostics that GCC issues without -pedantic ’ but treats as warnings. -M Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from ‘ -include ’ or -imacros ’ command line options.
Image of page 62

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

View Full Document Right Arrow Icon
Chapter 12: Invocation 59 Unless specified explicitly (with ‘ -MT ’ or ‘ -MQ ’), the object file name consists of the name of the source file with any suffix replaced with object file suffix and with any leading directory parts removed. If there are many included files then the rule is split into several lines using ‘ \ ’-newline. The rule has no commands. This option does not suppress the preprocessor’s debug output, such as ‘ -dM ’. To avoid mixing such debug output with the dependency rules you should ex- plicitly specify the dependency output file with ‘ -MF ’, or use an environment variable like DEPENDENCIES_OUTPUT (see Chapter 13 [Environment Variables], page 66 ). Debug output will still be sent to the regular output stream as normal.
Image of page 63
Image of page 64
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