Suppressing specific compiler warnings

DJ Delorie dj@redhat.com
Thu May 27 18:51:00 GMT 2004


> Whatever the details of the scheme, the mass of warning control
> infrastructure should be auto-constructed.

Just off the top of my head, something like this?

struct {
  const char *warning_name;
  unsigned flags; /* enabled, supressed, forced, error, c99, pedantic, translated, etc */
  const int pcode_index;
  const char *string;
} warnings[] = {
  . . .
  { "unbuttoned-fly", WF_ERROR|WF_PEDANTIC, 56,
    "your fly is unbuttoned" },
#define W_UNBUTTONED_FLY 47
  . . .
};

Which allows for...

	if (...)
	  warn(W_UNBUTTONED_FLY);

	#pragma warnings no-unbuttoned-fly

	gcc -wunbuttoned-fly

etc.  Sample database:

@unbuttoned-fly -error -pedantic +clothing
"your fly is unbuttoned"

The info_index is an index into a p-code table of relations between
this warning and, say, categories of warnings (like -Wclothing
enabling -Wunbuttoned-fly and other warnings).  Within the table,
negative values are actions, positive values refer to other warnings.



More information about the Gcc mailing list