Skip to content

Commit e81ddc2

Browse files
authored
Merge pull request #4690 from MidnightCommander/feature/use-compiler-attribute-detection
Use compiler attribute detection
2 parents befa9a0 + 85e1f45 commit e81ddc2

File tree

6 files changed

+17
-258
lines changed

6 files changed

+17
-258
lines changed

acinclude.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ m4_include([m4.include/ax_append_flag.m4])
1313
m4_include([m4.include/ax_append_compile_flags.m4])
1414
m4_include([m4.include/mc-cflags.m4])
1515
m4_include([m4.include/mc-stdckdint.m4])
16-
m4_include([m4.include/ax_gcc_func_attribute.m4])
1716
m4_include([m4.include/mc-get-fs-info.m4])
1817
m4_include([m4.include/mc-with-x.m4])
1918
m4_include([m4.include/mc-use-termcap.m4])

configure.ac

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ if test "x$enable_werror" = xyes; then
6464
AX_APPEND_COMPILE_FLAGS([-Werror], [mc_configured_cflags])
6565
fi
6666

67-
dnl Compiler can generate warnings for unrecognized flags added to CFLAGS
68-
dnl which causes attribute checks to fail
69-
ax_gcc_func_attribute_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
70-
_AC_LANG_PREFIX[]FLAGS=
71-
AX_GCC_FUNC_ATTRIBUTE([fallthrough])
72-
AX_GCC_FUNC_ATTRIBUTE([weak])
73-
AX_GCC_FUNC_ATTRIBUTE([unused])
74-
_AC_LANG_PREFIX[]FLAGS=$ax_gcc_func_attribute_save_flags
75-
unset ax_gcc_func_attribute_save_flags
76-
7767
LT_INIT
7868

7969

lib/global.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99

1010
#include <glib.h>
1111

12-
#if defined(HAVE_FUNC_ATTRIBUTE_WEAK) && defined(HAVE_TESTS)
12+
#if defined(__has_attribute)
13+
#define MC_HAS_ATTRIBUTE(ATTR) __has_attribute (ATTR)
14+
#else
15+
#define MC_HAS_ATTRIBUTE(ATTR) 0
16+
#endif
17+
18+
#if MC_HAS_ATTRIBUTE(weak) && defined(HAVE_TESTS)
1319
#define MC_MOCKABLE __attribute__ ((weak))
1420
#else
1521
#define MC_MOCKABLE
@@ -44,18 +50,24 @@
4450
#define N_(String) (String)
4551
#endif
4652

47-
#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
53+
#if MC_HAS_ATTRIBUTE(fallthrough)
4854
#define MC_FALLTHROUGH __attribute__ ((fallthrough))
4955
#else
5056
#define MC_FALLTHROUGH
5157
#endif
5258

53-
#ifdef HAVE_FUNC_ATTRIBUTE_UNUSED
59+
#if MC_HAS_ATTRIBUTE(unused)
5460
#define MC_UNUSED __attribute__ ((unused))
5561
#else
5662
#define MC_UNUSED
5763
#endif
5864

65+
#if MC_HAS_ATTRIBUTE(nonstring)
66+
#define MC_NONSTRING __attribute__ ((nonstring))
67+
#else
68+
#define MC_NONSTRING
69+
#endif
70+
5971
#ifdef USE_MAINTAINER_MODE
6072
#include "lib/logging.h"
6173
#endif

m4.include/ax_gcc_func_attribute.m4

Lines changed: 0 additions & 242 deletions
This file was deleted.

src/filemanager/find.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ static void
12201220
find_rotate_dash (const WDialog *h, gboolean show)
12211221
{
12221222
static size_t pos = 0;
1223-
static const char rotating_dash[4] = "|/-\\";
1223+
static const char rotating_dash[4] MC_NONSTRING = "|/-\\";
12241224
const Widget *w = CONST_WIDGET (h);
12251225
const int *colors;
12261226

src/filemanager/layout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ rotate_dash (gboolean show)
10661066
tty_print_alt_char (ACS_URCORNER, FALSE);
10671067
else
10681068
{
1069-
static const char rotating_dash[4] = "|/-\\";
1069+
static const char rotating_dash[4] MC_NONSTRING = "|/-\\";
10701070
static size_t pos = 0;
10711071

10721072
tty_print_char (rotating_dash[pos]);

0 commit comments

Comments
 (0)