pkginclude_HEADERS = cgraph.h
noinst_HEADERS = agxbuf.h alloc.h bitarray.h cghdr.h exit.h itos.h likely.h \
- prisize_t.h stack.h strcasecmp.h unreachable.h
+ prisize_t.h stack.h strcasecmp.h unreachable.h unused.h
noinst_LTLIBRARIES = libcgraph_C.la
lib_LTLIBRARIES = libcgraph.la
pkgconfig_DATA = libcgraph.pc
<ClInclude Include="stack.h" />
<ClInclude Include="strcasecmp.h" />
<ClInclude Include="unreachable.h" />
+ <ClInclude Include="unused.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="agerror.c" />
<ClInclude Include="unreachable.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="unused.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="agerror.c">
--- /dev/null
+/// \file
+/// \brief abstraction for squashing compiler warnings for unused symbols
+
+#pragma once
+
+/// squash an unused variable/function warning in C
+///
+/// e.g.
+///
+/// static UNUSED void my_uncalled_function(void) { }
+/// static UNUSED int my_unused_variable;
+///
+/// Use this sparingly, as the MSVC version applies to everything in both the
+/// current and next line, so can end up accidentally masking genuine problems.
+/// Only use this in C code. In C++, use `[[maybe_unused]]`.
+#ifdef __GNUC__ // Clang and GCC
+#define UNUSED __attribute__((unused))
+#elif defined(_MSC_VER) // MSVC
+#define UNUSED \
+ __pragma(warning(suppress : 4100 /* unreferenced formal parameter */ \
+ 4101 /* unreferenced local variable */ \
+ 4505 /* unreferenced local function */ \
+ ))
+#else
+#define UNUSED /* nothing */
+#endif