Skip to content

fix: add explicit STL headers and tighten two non-portable usages#58

Open
iamcheyan wants to merge 1 commit into
etorth:mainfrom
iamcheyan:fix/apple-clang-strict
Open

fix: add explicit STL headers and tighten two non-portable usages#58
iamcheyan wants to merge 1 commit into
etorth:mainfrom
iamcheyan:fix/apple-clang-strict

Conversation

@iamcheyan

Copy link
Copy Markdown
Contributor

GCC pulls a few common STL headers in transitively, and accepts a
couple of small non-portable patterns that Clang rejects. Apple
Clang and Clang in general do neither, so the project doesn't
compile out of the box on macOS / on a recent libc++ toolchain.

This PR is the minimal fix. None of these changes affect behaviour
or change Linux GCC builds.

Header completeness (transitive on GCC, not on Clang)

  • common/src/triangle.cpp<algorithm> (std::max / std::min)
  • common/src/log.hpp<unistd.h> (getpid())
  • common/src/buffrecord.hpp<cmath> (std::lround)
  • common/src/staticvector.hpp<span> (std::span)
  • common/src/protocoldef.hpp<utility> (std::move / std::forward)
  • client/src/layoutboard.cpp<ranges> (std::views)

Standards-conformance fixes

  • common/src/sdruntimeconfig.hpp — replace a =delete-on-template-
    specialization (a GCC extension) with static_assert. Clang
    requires =delete to appear on the first declaration of an
    entity; the existing form was non-standard.
  • common/src/zcompf.hpp — pass src directly instead of
    src.data(); the parameter is already a raw const uint8_t *,
    so .data() doesn't compile.

Tested

  • Apple Clang 17 (Xcode 17) on macOS arm64 — builds clean.
  • brew LLVM 22 on macOS arm64 — builds clean.
  • Should be a strict no-op on Linux GCC builds (only adds includes
    and replaces non-portable patterns with portable equivalents).

Apple Clang is stricter than GCC about transitive header inclusion
and a few other corners of the language. None of these changes alter
behavior; they just stop the build from breaking on macOS.

Header completeness (GCC pulled these in transitively):
  - common/src/triangle.cpp: <algorithm> for std::max / std::min
  - common/src/log.hpp: <unistd.h> for getpid()
  - common/src/buffrecord.hpp: <cmath> for std::lround
  - common/src/staticvector.hpp: <span> for std::span
  - common/src/protocoldef.hpp: <utility> for std::move / std::forward
  - client/src/layoutboard.cpp: <ranges> for std::views

Strict-conformance fixes:
  - common/src/sdruntimeconfig.hpp: replace `=delete` on a template
    specialization with static_assert. Clang requires `=delete` to
    appear on the first declaration; the existing usage was a GCC
    extension.
  - common/src/zcompf.hpp: pass src directly instead of src.data()
    -- the parameter is already a raw pointer.
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.

1 participant