[Bf-blender-cvs] [49f1695ed06] master: BLI_utildefines: add UNUSED_FUNCTION_WITH_RETURN_TYPE

Campbell Barton noreply at git.blender.org
Mon Sep 6 11:00:36 CEST 2021


Commit: 49f1695ed06792ea1f4d1a43d30170c407f227f8
Author: Campbell Barton
Date:   Mon Sep 6 18:57:25 2021 +1000
Branches: master
https://developer.blender.org/rB49f1695ed06792ea1f4d1a43d30170c407f227f8

BLI_utildefines: add UNUSED_FUNCTION_WITH_RETURN_TYPE

Unfortunately the UNUSED_FUNCTION macro doesn't work for pointer types.

Add UNUSED_FUNCTION_WITH_RETURN_TYPE to workaround this limitation.

===================================================================

M	source/blender/blenlib/BLI_utildefines.h
M	source/blender/makesrna/intern/rna_access.c

===================================================================

diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 5b84e050f82..dec8acd7549 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -683,12 +683,22 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
 #  define UNUSED(x) UNUSED_##x
 #endif
 
+/**
+ * WARNING: this doesn't warn when returning pointer types (because of the placement of `*`).
+ * Use #UNUSED_FUNCTION_WITH_RETURN_TYPE instead in this case.
+ */
 #if defined(__GNUC__) || defined(__clang__)
 #  define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_##x
 #else
 #  define UNUSED_FUNCTION(x) UNUSED_##x
 #endif
 
+#if defined(__GNUC__) || defined(__clang__)
+#  define UNUSED_FUNCTION_WITH_RETURN_TYPE(rtype, x) __attribute__((__unused__)) rtype UNUSED_##x
+#else
+#  define UNUSED_FUNCTION_WITH_RETURN_TYPE(rtype, x) rtype UNUSED_##x
+#endif
+
 /**
  * UNUSED_VARS#(a, ...): quiet unused warnings
  *
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index effc56b15c5..fceb6d045c3 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -5523,7 +5523,7 @@ char *RNA_path_append(
 
 /* Having both path append & back seems like it could be useful,
  * this function isn't used at the moment. */
-static char *UNUSED_FUNCTION(RNA_path_back)(const char *path)
+static UNUSED_FUNCTION_WITH_RETURN_TYPE(char *, RNA_path_back)(const char *path)
 {
   char fixedbuf[256];
   const char *previous, *current;



More information about the Bf-blender-cvs mailing list