Simplify wcast qual suppression (#167)
This change doesn't result in any change to the object code.
* Use simple way to suppress Wcast-qual warning
This method does not require pragmas, only cast over uintptr_t.
* Fix clang Wstrict-prototypes warning
A function declaration without a prototype is deprecated in all versions of C
Co-authored-by: Laurence Lundblade <laurencelundblade@users.noreply.github.com>
diff --git a/inc/qcbor/UsefulBuf.h b/inc/qcbor/UsefulBuf.h
index 8a101fd..e1b3146 100644
--- a/inc/qcbor/UsefulBuf.h
+++ b/inc/qcbor/UsefulBuf.h
@@ -673,15 +673,8 @@
{
UsefulBuf UB;
- // See UsefulBuf_Unconst() implementation for comment on pragmas
-#ifndef _MSC_VER
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
- UB.ptr = (void *)UBC.ptr;
-#ifndef _MSC_VER
-#pragma GCC diagnostic pop
-#endif
+ // See UsefulBuf_Unconst() implementation for comment
+ UB.ptr = (void *)(uintptr_t)UBC.ptr;
UB.len = UBC.len;
@@ -1759,16 +1752,9 @@
UsefulBuf UB;
/* -Wcast-qual is a good warning flag to use in general. This is
- * the one place in UsefulBuf where it needs to be quieted. Since
- * clang supports GCC pragmas, this works for clang too. */
-#ifndef _MSC_VER
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
- UB.ptr = (void *)UBC.ptr;
-#ifndef _MSC_VER
-#pragma GCC diagnostic pop
-#endif
+ * the one place in UsefulBuf where it needs to be quieted.
+ */
+ UB.ptr = (void *)(uintptr_t)UBC.ptr;
UB.len = UBC.len;