[vlc-devel] [PATCH] threads: forbid the use of vlc_cleanup_push/pop in portable C++ code

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 11 08:45:01 CET 2020


It may work for some C++ code only used on Linux. But if the module is compiled
on other platforms it will assert.
---
 include/vlc_threads.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 0e27ea803fa..5a75f4ad1f8 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -1084,12 +1084,10 @@ struct vlc_cleanup_t
         vlc_control_cancel (NULL); \
     } while (0)
 # else
-/* Those macros do not work in C++. However common C/C++ helpers may call them
- * anyway - this is fine if the code is never cancelled in C++ case.
- * So define the macros to do nothing.
- */
-#  define vlc_cleanup_push(routine, arg) do { (routine, arg)
-#  define vlc_cleanup_pop() } while (0)
+#  define vlc_cleanup_push(routine, arg) \
+    static_assert(false, "don't use vlc_cleanup_push in portable C++ code")
+#  define vlc_cleanup_pop() \
+    static_assert(false, "don'o't use vlc_cleanup_pop in portable C++ code")
 # endif
 
 #endif /* !LIBVLC_USE_PTHREAD_CLEANUP */
-- 
2.17.1



More information about the vlc-devel mailing list