Add a FALL_THROUGH macro to compiler.h

Older gcc's don't support `__attribute__ ((fallthrough))`
(see https://sourceforge.net/u/begasus/tuxpaint/ci/e5c3cdfcf5e16a9b0fc3e7766bfea1d9c326b3ae/
"Haiku Fixes" by Luc), so adding a new macro to compiler.h
that is defined as "((void)0)" on older compilers.
This commit is contained in:
Bill Kendrick 2019-09-12 20:27:03 -07:00
parent e5c3cdfcf5
commit df49986fab
2 changed files with 21 additions and 12 deletions

View file

@ -5,7 +5,7 @@
for Tux Paint
Mostly by Albert Cahalan <albert@users.sf.net>
Copyright (c) 2002-2006
Copyright (c) 2002-2019
http://www.newbreedsoftware.com/tuxpaint/
@ -24,7 +24,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - December 30, 2017
June 14, 2002 - September 12, 2019
$Id$
*/
@ -127,3 +127,13 @@
#undef CLOCK_ASM
#define CLOCK_ASM(x) x=42
#endif
/* h/t https://tutel.me/c/programming/questions/45349079/how+to+use+__attribute__fallthrough+correctly+in+gcc */
#ifndef FALLTHROUGH
#if defined(__GNUC__) && __GNUC__ >= 7
#define FALL_THROUGH __attribute__ ((fallthrough))
#else
#define FALL_THROUGH ((void)0)
#endif /* __GNUC__ >= 7 */
#endif