compiler: Provide LIBPLDM_CC_UNUSED

Ensure that we have __has_attribute available, and then further
ensure that the unused attribute is provided. Once satisfied, define
LIBPDLM_CC_UNUSED and replace raw use of __attribute__((unused)).

Change-Id: I2433039297d5fdedb8b8d99b30e73e4542d9069f
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/compiler.h b/src/compiler.h
index 31eeff9..e704518 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -2,6 +2,20 @@
 #ifndef PLDM_COMPILER_H
 #define PLDM_COMPILER_H
 
+#ifndef __has_attribute
+#error The libpldm implementation requires __has_attribute
+#endif
+
+#include <assert.h>
+
+static struct {
+	static_assert(__has_attribute(unused),
+		      "`unused` attribute is required");
+	int compliance;
+} pldm_required_attributes __attribute__((unused));
+
+#define LIBPLDM_CC_UNUSED __attribute__((unused))
+
 // NOLINTBEGIN(bugprone-macro-parentheses)
 /**
  * Require that the given object is of the specified type.