]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: make __attributes__ more portable
authorKarel Zak <kzak@redhat.com>
Tue, 5 Nov 2024 10:10:31 +0000 (11:10 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 5 Nov 2024 10:10:31 +0000 (11:10 +0100)
Let's use what is already used for libmount. The header file is a public
header and does not require support for the __attribute__() compiler
feature. We need an additional #ifdef to ensure portability.

Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/libsmartcols.h.in

index 3947673ba2965cbc74ab627146996dfb90e69b23..edee65b7e5c99aae63b9cc7f6f36b82b6014c3b0 100644 (file)
@@ -145,6 +145,23 @@ enum {
        SCOLS_CELL_FL_RIGHT   = (1 << 1)
 };
 
+
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+#  define __GNUC_PREREQ(maj, min)  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+#  define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+#ifndef __ul_attribute__
+# if __GNUC_PREREQ (3, 4)
+#  define __ul_attribute__(_a_) __attribute__(_a_)
+# else
+#  define __ul_attribute__(_a_)
+# endif
+#endif
+
 extern struct libscols_iter *scols_new_iter(int direction);
 extern void scols_free_iter(struct libscols_iter *itr);
 extern void scols_reset_iter(struct libscols_iter *itr, int direction);
@@ -293,17 +310,17 @@ extern struct libscols_cell *scols_line_get_column_cell(
 extern int scols_line_set_data(struct libscols_line *ln, size_t n, const char *data);
 extern int scols_line_refer_data(struct libscols_line *ln, size_t n, char *data);
 extern int scols_line_vprintf(struct libscols_line *ln, size_t n, const char *fmt, va_list ap)
-       __attribute__((format(printf, 3, 0)));
+       __ul_attribute__((format(printf, 3, 0)));
 extern int scols_line_sprintf(struct libscols_line *ln, size_t n, const char *fmt, ...)
-       __attribute__((format(printf, 3, 4)));
+       __ul_attribute__((format(printf, 3, 4)));
 extern int scols_line_is_filled(struct libscols_line *ln, size_t n);
 extern int scols_line_set_column_data(struct libscols_line *ln, struct libscols_column *cl, const char *data);
 extern const char *scols_line_get_column_data(struct libscols_line *ln, struct libscols_column *cl);
 extern int scols_line_refer_column_data(struct libscols_line *ln, struct libscols_column *cl, char *data);
 extern int scols_line_vprintf_column(struct libscols_line *ln, struct libscols_column *cl, const char *fmt, va_list ap)
-       __attribute__((format(printf, 3, 0)));
+       __ul_attribute__((format(printf, 3, 0)));
 extern int scols_line_sprintf_column(struct libscols_line *ln, struct libscols_column *cl, const char *fmt, ...)
-       __attribute__((format(printf, 3, 4)));
+       __ul_attribute__((format(printf, 3, 4)));
 extern struct libscols_line *scols_copy_line(const struct libscols_line *ln);
 
 /* table */