728 | | Available since GCC version 4.6, this pragma lets you restore diagnostic options that were remembered by a diagnostic push. This pragma can occur on any line of a file. The number of pops is limited by memory and the size of an int index into the diagnostic information. At a pop information is moved from the table used by push into a history. An unbalanced pop, i.e. popping when nothing is on the stack is harmless and will simply reassert the user's command line diagnostic choices. |
| 728 | Available since GCC version 4.6, this pragma lets you restore diagnostic options that were remembered by a diagnostic push. This pragma can occur on any line of a file. The number of pops is limited by memory and the size of an int index into the diagnostic information. At a pop information is moved from the table used by push into a history. An unbalanced pop, i.e. popping when nothing is on the stack is harmless and will simply reassert the user's command line diagnostic choices. Be careful, though, that you don't pop to soon. In this example: |
| 729 | {{{ |
| 730 | foo() |
| 731 | { |
| 732 | int unused,i; |
| 733 | i=3; |
| 734 | } |
| 735 | }}} |
| 736 | We might want to suppress the unused variable like this: |
| 737 | {{{ |
| 738 | foo() |
| 739 | { |
| 740 | #pragma GCC diagnostic push |
| 741 | #pragma GCC diagnostic "-Wunused-variable" |
| 742 | int unused,i; |
| 743 | #pragma GCC diagnostic pop |
| 744 | i=3; |
| 745 | } |
| 746 | }}} |
| 747 | and then be surprised that we still get a warning about an unused variable. The reason is, that GCC doesn't know the variable is unused until it hits the closing brace. That means the pop has to come after the closing brace: |
| 748 | {{{ |
| 749 | foo() |
| 750 | { |
| 751 | #pragma GCC diagnostic push |
| 752 | #pragma GCC diagnostic "-Wunused-variable" |
| 753 | int unused,i; |
| 754 | i=3; |
| 755 | } |
| 756 | #pragma GCC diagnostic pop |
| 757 | }}} |
| 758 | |