Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/amachronic/microtar.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-11-06 18:58:39 +0300
committerAidan MacDonald <amachronic@protonmail.com>2021-11-06 18:58:39 +0300
commitd7015e92a719c9a8cf46217d2901eceeff6ffbbc (patch)
tree8bbd4ad3af16a001fc17fb0bbb45c28ef26a7e23
parent4b3e047ec696b124db903212615ffeef2d15b2bc (diff)
Add GCC version check for #pragma
-rw-r--r--src/microtar.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/microtar.c b/src/microtar.c
index ddd0c0c..2cb9733 100644
--- a/src/microtar.c
+++ b/src/microtar.c
@@ -222,7 +222,7 @@ static int header_to_raw(char* raw, const mtar_header_t* h)
raw[TYPE_OFF] = h->type ? h->type : MTAR_TREG;
-#ifdef __GNUC__
+#if defined(__GNUC__) && (__GNUC__ >= 8)
/* Sigh. GCC wrongly assumes the output of strncpy() is supposed to be
* a null-terminated string -- which it is not, and we are relying on
* that fact here -- and tries to warn about 'string truncation' because
@@ -234,7 +234,7 @@ static int header_to_raw(char* raw, const mtar_header_t* h)
strncpy(&raw[NAME_OFF], h->name, NAME_LEN);
strncpy(&raw[LINKNAME_OFF], h->linkname, LINKNAME_LEN);
-#ifdef __GNUC__
+#if defined(__GNUC__) && (__GNUC__ >= 8)
# pragma GCC diagnostic pop
#endif