Why do pragmas occur after a line in GCC?

Why do pragmas occur after a line in GCC?

GCC keeps track of the location of each pragma, and issues diagnostics according to the state as of that point in the source file. Thus, pragmas occurring after a line do not affect diagnostics caused by that line. Causes GCC to remember the state of the diagnostics as of each push, and restore to that point at each pop.

What are the diagnostic pragmas in GCC 6.62.13?

6.62.13 Diagnostic Pragmas. GCC allows the user to selectively enable or disable certain types of diagnostics, and change the kind of the diagnostic. For example, a project’s policy might require that all sources compile with -Werror but certain files might have exceptions allowing specific types of warnings.

What causes GCC to remember the state of the diagnostics?

Causes GCC to remember the state of the diagnostics as of each push, and restore to that point at each pop. If a pophas no matching push, the command-line options are restored.

What happens when pop has no matching push in GCC?

If a pop has no matching push, the command-line options are restored. GCC also offers a simple mechanism for printing messages during compilation. Prints string as a compiler message on compilation. The message is informational only, and is neither a compilation warning nor an error.

GCC keeps track of the location of each pragma, and issues diagnostics according to the state as of that point in the source file. Thus, pragmas occurring after a line do not affect diagnostics caused by that line. Causes GCC to remember the state of the diagnostics as of each push, and restore to that point at each pop.

6.62.13 Diagnostic Pragmas. GCC allows the user to selectively enable or disable certain types of diagnostics, and change the kind of the diagnostic. For example, a project’s policy might require that all sources compile with -Werror but certain files might have exceptions allowing specific types of warnings.

How to treat a diagnostic in GCC as an error?

kindis ‘error’ to treat this diagnostic as an error, ‘warning’ to treat it like a warning (even if -Werroris in effect), or ‘ignored’ if the diagnostic is to be ignored. optionis a double quoted string that matches the command-line option.

Is there a way to disable wunknown pragmas in GCC?

I’m using g++ (version 4.7.1) with -Wall and -std=c++0x under Debian. I’ve run into this annoyance, too. According to the GCC manpage -Wall turns on -Wunknown-pragmas for you, so just manually disable it using -Wno-unknown-pragmas after -Wall.