1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-31 00:03:07 +03:00

cmake: Add check for fallthrough attribute

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2017-08-25 10:00:08 +02:00
parent 7204d2f485
commit a9846ccc0d
2 changed files with 29 additions and 0 deletions

View File

@ -242,6 +242,33 @@ int main(void) {
return 0; return 0;
}" HAVE_MSC_THREAD_LOCAL_STORAGE) }" HAVE_MSC_THREAD_LOCAL_STORAGE)
check_c_source_compiles("
#define FALL_THROUGH __attribute__((fallthrough))
enum direction_e {
UP = 0,
DOWN,
};
int main(void) {
enum direction_e key = UP;
int i = 10;
int j = 0;
switch (key) {
case UP:
i = 5;
FALL_THROUGH;
case DOWN:
j = i * 2;
break;
default:
break;
}
return 0;
}" HAVE_FALLTHROUGH_ATTRIBUTE)
check_c_source_compiles(" check_c_source_compiles("
#include <string.h> #include <string.h>

View File

@ -167,6 +167,8 @@
#cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1 #cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
#cmakedefine HAVE_MSC_THREAD_LOCAL_STORAGE 1 #cmakedefine HAVE_MSC_THREAD_LOCAL_STORAGE 1
#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
#cmakedefine HAVE_GCC_VOLATILE_MEMORY_PROTECTION 1 #cmakedefine HAVE_GCC_VOLATILE_MEMORY_PROTECTION 1
#cmakedefine HAVE_GCC_NARG_MACRO 1 #cmakedefine HAVE_GCC_NARG_MACRO 1