From 43517cd882fa2f657eee47d4a2e8f311a87daf50 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 2 Dec 2024 10:10:49 +0100 Subject: [PATCH] pam: unused compat (c++ 14) --- src/utils/pam.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/utils/pam.hpp b/src/utils/pam.hpp index bc62fd14b..3003ca999 100644 --- a/src/utils/pam.hpp +++ b/src/utils/pam.hpp @@ -45,13 +45,25 @@ #include #include +#define PAM_ATTR(a) + #if __cplusplus >= 201703L #define MAYBE_UNUSED [[maybe_unused]] #else #define MAYBE_UNUSED +#ifdef __GNUC__ +#undef PAM_ATTR +#define PAM_ATTR(a) __attribute__((a)) +#endif #endif -MAYBE_UNUSED static bool pam_read(const char *filename, unsigned int *width, unsigned int *height, int *depth, unsigned char **data, void *(*allocator)(size_t) = malloc) { +MAYBE_UNUSED static bool +pam_read(const char *filename, unsigned int *width, unsigned int *height, + int *depth, unsigned char **data, void *(*allocator)(size_t) = malloc) PAM_ATTR(unused); +static bool +pam_read(const char *filename, unsigned int *width, unsigned int *height, + int *depth, unsigned char **data, void *(*allocator)(size_t)) +{ try { std::string line; std::ifstream file(filename, std::ifstream::in | std::ifstream::binary); @@ -113,7 +125,13 @@ MAYBE_UNUSED static bool pam_read(const char *filename, unsigned int *width, uns return true; } -MAYBE_UNUSED static bool pam_write(const char *filename, unsigned int width, unsigned int height, int depth, const unsigned char *data) { +MAYBE_UNUSED static bool pam_write(const char *filename, unsigned int width, + unsigned int height, int depth, + const unsigned char *data) PAM_ATTR(unused); +static bool +pam_write(const char *filename, unsigned int width, unsigned int height, + int depth, const unsigned char *data) +{ try { std::ofstream file(filename, std::ifstream::out | std::ifstream::binary);