Skip to Content
CTech Digital
  • Home
  • Odoo services
  • AI services
  • Contact us
  • 0
  • Nederlands (BE) English (UK) Français
CTech Digital
  • 0
    • Home
    • Odoo services
    • AI services
    • Contact us
  • Nederlands (BE) English (UK) Français

Reworking measurements of geometries

  • All Blogs
  • Daily blog
  • Reworking measurements of geometries
  • 21 October 2025 by
    CTech Metrology, Luc Wens
    • CAlign->MeasureInit
      • SetCADShow(false)
      • MeasureInitPointCloud


    Attempt to switch to c++20

    Failed because of these errors

    Group 1: Stricter Reference Binding

    Problem: Passing a temporary object (rvalue) to a function parameter that is a non-const lvalue reference (&). C++20 strictly prohibits this, whereas C++17 (especially MSVC) was more permissive.

    • 'initializing': cannot convert from 'std::_Tree_iterator<...>' to 'std::_Tree_iterator<...> &'

    • 'void CInterpolator::SetTable(...)': cannot convert argument 1 from 'std::vector<...>' to 'std::vector<...> &'

    • 'LPDISPATCH ...': cannot convert argument 1 from 'COleVariant' to 'VARIANT &'

    Solution: Store the temporary object in a named variable first, then pass that variable to the function.

    Group 2: Stricter const Correctness (String Literals)

    Problem: Passing a string literal (e.g., "hello", which is const char[]) to a function expecting a non-const char*. Modifying string literals is undefined behavior, and C++20 now enforces this as an error.

    • 'initializing': cannot convert from 'const char [10]' to 'char *'

    • 'int TransputerLoadSystem(char *)': cannot convert argument 1 from 'const char [7]' to 'char *'

    Solution: Change the function parameter to accept const char* instead of char*.

    Group 3: Stricter or Removed Implicit Conversions

    Problem: Implicit type conversions that worked in C++17 (e.g., CString to std::string, bool to HANDLE) are no longer allowed due to C++20's stricter rules for overload resolution and explicit constructors.

    • 'return': cannot convert from 'CString' to 'std::basic_string<...>'

    • 'return': cannot convert from 'bool' to 'HANDLE'

    Solution: Add an explicit cast to make the conversion, e.g., return std::string(myCString); or return (HANDLE)myBool;.

    Group 4: Compile-Time Expression (consteval) Errors

    Problem: Using a string known only at runtime (e.g., from a file) with C++20's std::format or the {fmt} library. These tools use consteval to parse format strings at compile time.

    • 'fmt::...basic_format_string': call to immediate function is not a constant expression

    Solution: If the format string must be dynamic, wrap it in fmt::runtime() to signal that it should be parsed at runtime.

    Group 5: Stricter std::function Type Matching

    Problem: A subtle mismatch in function signatures, such as providing a std::function<void(T&)> (takes by reference) when a std::function<void(T)> (takes by value) is expected.

    • 'void ... SetAfterTaskFinish(...)': cannot convert argument 1 from 'std::function<void (CMeasuredPoint &)>' to 'std::function<void (CMeasuredPoint)>'

    Solution: Use a lambda to manually adapt the signature (e.g., [myFunc](CMeasuredPoint p) { myFunc(p); }).

    Group 6: Ambiguous Ternary Operator (?:)

    Problem: The compiler cannot determine a single common type for the two results of a conditional operator (e.g., one branch is CString, the other is const char*).

    • result type ... is ambiguous: types 'CString' and 'const char [1]' can be converted to multiple common types

    Solution: Explicitly cast one or both sides to the desired common type (e.g., std::string(s)).

    Group 7: Deprecated Pointer/Integer Comparisons

    Problem: Using ordered comparisons (<, >, <=, >=) between a pointer and the integer 0. C++20 removes this C-style pattern.

    • '>': ordered comparison of pointer and integer zero ('char *' and 'int')

    Solution: Use != nullptr for the check, or rely on the implicit boolean conversion (e.g., if (myPtr)).

    ​

    in Daily blog
    # CTrack
    Xenomatix Xavia
    Copyright © CTech
    Nederlands (BE) | English (UK) | Français
    Powered by Odoo - The #1 Open Source eCommerce