Re: [PATCH] silence warnings

Andre Noll <[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
On 11:38, Bernhard R. Link wrote:

> * empty if or else branches
> as PRINT_DEBUG is sometimes empty, gcc warns about empty if and else
> braches. With some { } that stops (though other compilers might warn
> more). But I think this way it is "safest" to have no ugly effects
> (not that the danger was more than insignificant before)...

One common approach to deal with macros that might expand to nothing
is using constructs like

	#define PRINT_DEBUG(foo) do { ... } while (0)

This avoids all warnings and works for all compilers. More importantly,
it catches the following class of bugs:

	if (foo)
		PRINT_DEBUG(...)
	statement;

If PRINT_DEBUG(...) expands to nothing, the compiler will _not_
complain about the missing semicolon, and the code does _not_ do what
is suggested by the indentation.

Just my 2 cent.
Andre
-- 
The only person who always got his work done by Friday was Robinson Crusoe

_______________________________________________
Ratpoison-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/ratpoison-devel
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFJ9uLHWto1QDEAkw8RAsbiAJ9mQ+6O+0d6B/5J4QLNe0ZtSd6dtQCdHUfT
C9SQ98/e27jkedx01sJSJd4=
=/Ty1
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.