commit 62f0921bc37a6298884c03bd56adff85beb424f4
Author: Scott Kostyshak <[email protected]>
Date:   Sat Jul 5 11:02:40 2025 +0200

    Use macros that were not meant to be used
    
    The macros UpdateLocker and PathChanger were introduced as a way to
    catch incorrect usage of the corresponding classes.
    
    e.g., the intended way to use UpdateLocker is:
    
      UpdateLocker locker(...);
    
    The incorrect way to use it is:
    
      UpdateLocker(...);
    
    The macro protects against the incorrect usage.
    
    Thus, it is defined but not intended to be used in our code.
    However, this triggered warnings about unused macros. This commit
    then uses the macros in a no-op way. This approach is documented
    here:
    
      https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
    
    This commit fixes warnings from Clang and GCC. Here are the GCC
    warnings:
    
      src/support/PathChanger.cpp:65: warning: macro "PathChanger" is not used 
[-Wunused-macros]
    
      src/mathed/InsetMathMacro.cpp:682: warning: macro "UpdateLocker" is not 
used [-Wunused-macros]
---
 src/mathed/InsetMathMacro.cpp | 3 +++
 src/support/PathChanger.cpp   | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 8efed741b0..ece9bfd39d 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -681,6 +681,9 @@ private:
 */
 #define UpdateLocker(x) unnamed_UpdateLocker;
 // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
+// Now we no-op use it to avoid -Wunused-macros
+#if defined UpdateLocker
+#endif
 
 
 void InsetMathMacro::updateRepresentation(Cursor * cur, MacroContext const & 
mc,
diff --git a/src/support/PathChanger.cpp b/src/support/PathChanger.cpp
index 999a7c5913..0c8f34a060 100644
--- a/src/support/PathChanger.cpp
+++ b/src/support/PathChanger.cpp
@@ -60,8 +60,11 @@ int PathChanger::pop()
 
 } // namespace support
 } // namespace lyx
-
-
+//
+// grep for 'unnamed_UpdateLocker' and corresponding comment for
+// the purpose of this chunk.
 #define PathChanger(x) unnamed_PathChanger;
+#if defined PathChanger
+#endif
 
 // in merged builds this is not the last line.
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to