ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] GCC Diagnostic Pragmas

From: Jakub Zawadzki <darkjames-ws@xxxxxxxxxxxx>
Date: Sat, 9 Nov 2013 13:39:30 +0100
Hi,

In few dissectors we're manually disabling some kind of warnings, like
in packet-parlay.c

#ifdef _MSC_VER
/* disable warning: "unreference local variable" */
#pragma warning(disable:4101)
#endif

It's possible to do the same with GCC (4.6) using diagnostics pragmas[1].


Googling around found test:

#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6 || __APPLE_CC__))
# pragma GCC diagnostic ignored "-Wunused"
#endif

which seems to be not working with my clang-3.3.

qemu does test during configure, trying to compile some test program with -Werror.

I think we could do the same, test program can looks like this:
#v+
	#pragma GCC diagnostic push
	#pragma GCC diagnostic ignored "-Wunused"
	#pragma GCC diagnostic pop

	int main(void) {
	    return 0;
	}
#v-

OK?

[1] http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html