Skip to content

Fix compile failure on MacOS X#1373

Closed
zedinosaur wants to merge 2 commits intomobile-shell:masterfrom
zedinosaur:macos-buildfix
Closed

Fix compile failure on MacOS X#1373
zedinosaur wants to merge 2 commits intomobile-shell:masterfrom
zedinosaur:macos-buildfix

Conversation

@zedinosaur
Copy link
Contributor

std::shared_ptr::unique() is deprecated in C++17 and removed in C++20.

Inspired by PR#1362.

Snippet of the failure:

In file included from ../../src/terminal/terminal.h:42:
../../src/terminal/terminalframebuffer.h:431:23: error: 'unique' is deprecated [-Werror,-Wdeprecated-declarations]
  431 |     if ( !mutable_row.unique() ) {
      |                       ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:752:3: note: 'unique' has been explicitly marked deprecated here
  752 |   _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI bool unique() const _NOEXCEPT { return use_count() == 1; }
      |   ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:731:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
  731 | #    define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
      |                                         ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:696:49: note: expanded from macro '_LIBCPP_DEPRECATED'
  696 | #      define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
      |                                                 ^
1 error generated.

std::shared_ptr::unique() is deprecated in C++17 and removed in C++20.

Inspired by PR#1362.

Snippet of the failure:

```
In file included from ../../src/terminal/terminal.h:42:
../../src/terminal/terminalframebuffer.h:431:23: error: 'unique' is deprecated [-Werror,-Wdeprecated-declarations]
  431 |     if ( !mutable_row.unique() ) {
      |                       ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:752:3: note: 'unique' has been explicitly marked deprecated here
  752 |   _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI bool unique() const _NOEXCEPT { return use_count() == 1; }
      |   ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:731:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
  731 | #    define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
      |                                         ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:696:49: note: expanded from macro '_LIBCPP_DEPRECATED'
  696 | #      define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
      |                                                 ^
1 error generated.
```
@eminence
Copy link
Member

Isn't this a duplicate of #1362 ?

@zedinosaur
Copy link
Contributor Author

It is sort of a duplicate of #1362.

This still isn't compiling due lots of failures that look like this:

In file included from transportfragment.cc:37:
In file included from ../../src/protobufs/transportinstruction.pb.h:20:
In file included from /opt/homebrew/Cellar/protobuf/33.4_1/include/google/protobuf/io/coded_stream.h:109:
In file included from /opt/homebrew/Cellar/abseil/20260107.0/include/absl/log/absl_log.h:36:
In file included from /opt/homebrew/Cellar/abseil/20260107.0/include/absl/log/internal/log_impl.h:22:
/opt/homebrew/Cellar/abseil/20260107.0/include/absl/log/internal/log_message.h:76:26: error: type nullability specifier '_Nonnull' is a Clang extension [-Werror,-Wnullability-extension]
   76 |   LogMessage(const char* absl_nonnull file, int line,
      |                          ^
/opt/homebrew/Cellar/abseil/20260107.0/include/absl/base/nullability.h:240:22: note: expanded from macro 'absl_nonnull'
  240 | #define absl_nonnull _Nonnull
      |                      ^

Which is odd since I would assume this was being compiled with clang on macos.

Protobuf uses nullability extensions so this warning needs to be disabled.
@zedinosaur
Copy link
Contributor Author

More problems:

c++ -std=gnu++17 -DHAVE_CONFIG_H -I. -I../../src/include  -I../../ -I/opt/homebrew/Cellar/protobuf/33.4_1/include -DPROTOBUF_USE_DLLS -I/opt/homebrew/Cellar/abseil/20260107.1/include -Wno-float-conversion -Wno-implicit-float-conversion -Wno-implicit-int-float-conversion -Wno-unknown-warning-option -Wno-unused-command-line-argument -DNOMINMAX  -Wall -Werror -Wno-c++17-extensions -Wextra -pedantic -Wno-long-long -Weffc++ -Wmissing-declarations -Wno-unused-parameter -Wno-nullability-extension -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE -pipe  -g -O2 -MT transportfragment.o -MD -MP -MF .deps/transportfragment.Tpo -c -o transportfragment.o transportfragment.cc
In file included from transportfragment.cc:37:
In file included from ../../src/protobufs/transportinstruction.pb.h:20:
In file included from /opt/homebrew/Cellar/protobuf/33.4_1/include/google/protobuf/io/coded_stream.h:113:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/strings/cord.h:80:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/crc/internal/crc_cord_state.h:23:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/crc/crc32c.h:32:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/strings/str_format.h:83:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/strings/internal/str_format/arg.h:36:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/numeric/int128.h:41:
/opt/homebrew/Cellar/abseil/20260107.1/include/absl/types/compare.h:78:22: error: 'enable_if' is a clang extension [-Werror,-Wgcc-compat]
   78 |       __attribute__((enable_if(n == 0, "Only literal `0` is allowed."))) {}
      |                      ^

and

In file included from transportfragment.cc:37:
In file included from ../../src/protobufs/transportinstruction.pb.h:28:
In file included from /opt/homebrew/Cellar/protobuf/33.4_1/include/google/protobuf/extension_set.h:36:
In file included from /opt/homebrew/Cellar/abseil/20260107.1/include/absl/container/btree_map.h:67:
/opt/homebrew/Cellar/abseil/20260107.1/include/absl/container/internal/btree_container.h:524:30: error: passing no argument for the '...' parameter of a variadic macro is a C++20 extension [-Werror,-Wvariadic-macro-arguments-omitted]
  524 |                   false, true);
      |                              ^

This looks like these warnings are coming from the -pedantic flag. There's some indication that abseil can't really be compiled with -pedantic (abseil/abseil-cpp#157) since it uses a number of extensions conditionally and intentionally. Maybe it should be removed and more targeted warning flags enabled?

zedinosaur added a commit to zedinosaur/mosh that referenced this pull request Feb 23, 2026
Abseil uses certain compiler extensions intentionally (see abseil/abseil-cpp#157) so it triggers multiple warnings enabled by -pedantic (-Wnullability-extension, -Wgcc-compat, -Wvariadic-macro-arguments-omitted at a minimum) as seen in mobile-shell#1373.
@zedinosaur
Copy link
Contributor Author

Closing this in favor of #1374 instead.

@zedinosaur zedinosaur closed this Feb 23, 2026
zedinosaur added a commit to zedinosaur/mosh that referenced this pull request Feb 23, 2026
Abseil uses certain compiler extensions intentionally (see abseil/abseil-cpp#157) so it triggers multiple warnings enabled by -pedantic (-Wnullability-extension, -Wgcc-compat, -Wvariadic-macro-arguments-omitted at a minimum) as seen in mobile-shell#1373.
achernya pushed a commit that referenced this pull request Feb 27, 2026
Abseil uses certain compiler extensions intentionally (see abseil/abseil-cpp#157) so it triggers multiple warnings enabled by -pedantic (-Wnullability-extension, -Wgcc-compat, -Wvariadic-macro-arguments-omitted at a minimum) as seen in #1373.
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