Skip to content

Provide a well-defined off_t type across different operating system platforms. #50

Closed
@Bill-hbrhbr

Description

@Bill-hbrhbr

Bug

off_t lives under <sys/types.h> for Linux platforms. However, on MacOS platforms, this is not the case, and clang-tidy will generate misc-include-cleaner warnings.

2 warnings treated as errors
/Users/runner/work/ystdlib-cpp/ystdlib-cpp/src/ystdlib/io_interface/StreamInterface.hpp:4:1: error: included header types.h is not used directly [misc-include-cleaner,-warnings-as-errors]
    4 | #include <sys/types.h>
      | ^~~~~~~~~~~~~~~~~~~~~~
    5 | 
/Users/runner/work/ystdlib-cpp/ystdlib-cpp/src/ystdlib/io_interface/StreamInterface.hpp:55:50: error: no header providing "off_t" is directly included [misc-include-cleaner,-warnings-as-errors]
    4 |     [[nodiscard]] virtual auto seek_from_current(off_t offset)
      |                                                  ^
task: Failed to run task "lint:check": exit status 1

This issue is first encountered when clang-tidying the ReaderInterface and WriterInterface classes in the io_interface library (#49). We've left NOLINTs and TODOs in the code to silence the warnings.

One solution is to create our own versions of the system headers for portability and platform-specific handling. See also.

ystdlib-cpp version

0.0.0

Environment

Warnings generated on MacOS-15.

Reproduction steps

Remove the NOLINT lines added in (#49), and run clang-tidy on MacOS-15.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions