mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-25 07:22:00 +00:00
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.
So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).
Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.
Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).
All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
|
||
|---|---|---|
| .. | ||
| android | ||
| arm | ||
| cocoa | ||
| directfb | ||
| dummy | ||
| emscripten | ||
| haiku | ||
| khronos | ||
| kmsdrm | ||
| nacl | ||
| offscreen | ||
| os2 | ||
| pandora | ||
| psp | ||
| qnx | ||
| raspberry | ||
| riscos | ||
| uikit | ||
| vita | ||
| vivante | ||
| wayland | ||
| windows | ||
| winrt | ||
| x11 | ||
| yuv2rgb | ||
| SDL_blit.c | ||
| SDL_blit.h | ||
| SDL_blit_0.c | ||
| SDL_blit_1.c | ||
| SDL_blit_A.c | ||
| SDL_blit_auto.c | ||
| SDL_blit_auto.h | ||
| SDL_blit_copy.c | ||
| SDL_blit_copy.h | ||
| SDL_blit_N.c | ||
| SDL_blit_slow.c | ||
| SDL_blit_slow.h | ||
| SDL_bmp.c | ||
| SDL_clipboard.c | ||
| SDL_egl.c | ||
| SDL_egl_c.h | ||
| SDL_fillrect.c | ||
| SDL_pixels.c | ||
| SDL_pixels_c.h | ||
| SDL_rect.c | ||
| SDL_rect_c.h | ||
| SDL_RLEaccel.c | ||
| SDL_RLEaccel_c.h | ||
| SDL_shape.c | ||
| SDL_shape_internals.h | ||
| SDL_stretch.c | ||
| SDL_surface.c | ||
| SDL_sysvideo.h | ||
| SDL_video.c | ||
| SDL_vulkan_internal.h | ||
| SDL_vulkan_utils.c | ||
| SDL_yuv.c | ||
| SDL_yuv_c.h | ||
| sdlgenblit.pl | ||