Skip to content

[#24574] Disable file watching on macOS and remove invalid InternalPtrData move#157

Open
Danipiza wants to merge 2 commits into
mainfrom
fix/macos_filewatcher
Open

[#24574] Disable file watching on macOS and remove invalid InternalPtrData move#157
Danipiza wants to merge 2 commits into
mainfrom
fix/macos_filewatcher

Conversation

@Danipiza
Copy link
Copy Markdown
Contributor

@Danipiza Danipiza commented May 28, 2026

Description

This PR improves native macOS compatibility in cpp_utils.

Changes

  • Disable FileWatcher on macOS by using a no-op backend under __APPLE__.
  • Keep FileWatcherHandler behavior explicit by logging that file watching is disabled on macOS.
  • Remove the InternalPtrData move constructor, which attempted to move a std::shared_timed_mutex.

Why

The bundled filewatch backend only supports Windows and Linux (inotify), so native macOS builds had no valid code path.

Also, InternalPtrData tried to move a mutex:

  • std::shared_timed_mutex is not movable by standard definition
  • Apple Clang/libc++ correctly rejects this
  • removing the move constructor makes the type standards-compliant

Error

Starting >>> cpp_utils
--- stderr: cpp_utils                             
In file included from /Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/src/cpp/event/FileWatcherHandler.cpp:25:
In file included from /Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/src/cpp/event/FileWatcher.hpp:21:
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:98:11: error: initializer '_directory' does not name a non-static data member or base class; did you mean the member '_destory'?
   98 |         , _directory(get_directory(path))
      |           ^~~~~~~~~~
      |           _destory
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:171:23: note: '_destory' declared here
  171 |     std::atomic<bool> _destory = { false };
      |                       ^
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:132:9: error: use of undeclared identifier '_directory'; did you mean '_destory'?
  132 |         _directory = get_directory(other._path);
      |         ^~~~~~~~~~
      |         _destory
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:171:23: note: '_destory' declared here
  171 |     std::atomic<bool> _destory = { false };
      |                       ^
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:249:33: error: use of undeclared identifier 'monitor_directory'
  249 |                                 monitor_directory();
      |                                 ^
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:98:22: error: use of undeclared identifier 'get_directory'
   98 |         , _directory(get_directory(path))
      |                      ^
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/../thirdparty/filewatch/FileWatch.hpp:106:11: note: in instantiation of member function 'filewatch::FileWatch<std::string>::FileWatch' requested here
  106 |         : FileWatch<T>(path, UnderpinningRegex(_regex_all), callback)
      |           ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__memory/unique_ptr.h:728:32: note: in instantiation of member function 'filewatch::FileWatch<std::string>::FileWatch' requested here
  728 |     return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
      |                                ^
/Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/src/cpp/event/FileWatcherHandler.cpp:61:36: note: in instantiation of function template specialization 'std::make_unique<eprosima::utils::event::FileWatcher, std::string &, (lambda at /Users/macmini/workspace_dev_utils/src/dev-utils/cpp_utils/src/cpp/event/FileWatcherHandler.cpp:63:13)>' requested here
   61 |         file_watch_handler_ = std::make_unique<FileWatcher>(
      |                                    ^
4 errors generated.
make[2]: *** [CMakeFiles/cpp_utils.dir/src/cpp/event/FileWatcherHandler.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/cpp_utils.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< cpp_utils [1.54s, exited with code 2]

Summary: 5 packages finished [3.30s]
  1 package failed: cpp_utils
  3 packages had stderr output: cpp_utils fastcdr fastdds

@Danipiza Danipiza changed the title [#24574] Disable file watching on macOS and remove invalid InternalPt… [#24574] Disable file watching on macOS and remove invalid InternalPtrData move May 28, 2026
…rData move

Signed-off-by: danipiza <dpizarrogallego@gmail.com>
Signed-off-by: danipiza <dpizarrogallego@gmail.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.30%. Comparing base (6031d4e) to head (6669e32).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cpp_utils/src/cpp/event/FileWatcherHandler.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
- Coverage   60.41%   60.30%   -0.11%     
==========================================
  Files          65       65              
  Lines        1945     1945              
  Branches      552      552              
==========================================
- Hits         1175     1173       -2     
- Misses        449      450       +1     
- Partials      321      322       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Danipiza Danipiza requested a review from ZakariaTalbi May 28, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants