Skip to content

Public header git2/sys/stream.h uses ssize_t, undefined for MSVC/clang-cl consumers #7286

@odrobnik

Description

@odrobnik

Summary

The public header git2/sys/stream.h declares the git_stream read/write callbacks using ssize_t (v1.9.4, lines 59–60):

ssize_t GIT_CALLBACK(read)(struct git_stream *, void *, size_t);
ssize_t GIT_CALLBACK(write)(struct git_stream *, const char *, size_t, int);

ssize_t is POSIX, not ISO C, and is not provided by MSVC / clang-cl. The only definition in the tree is the internal src/util/win32/msvc-compat.h (typedef SSIZE_T ssize_t;), which is not part of the public/installed headers. So a Windows consumer that includes git2/sys/stream.h — e.g. to register a custom stream backend via git_stream_register — fails to compile, e.g. with clang-cl:

error: unknown type name 'ssize_t'

git2.h does not pull in sys/stream.h, so this only affects consumers using the stream/transport plugin API directly — but for those it's a hard compile error on Windows with no public type to fall back on.

Suggested fix

Make ssize_t available from a public header on Windows before it's used (in git2/sys/stream.h, or a small shared public compat shim), mirroring what msvc-compat.h already does internally:

#if defined(_WIN32) && !defined(__MINGW32__) && !defined(_SSIZE_T_DEFINED)
# include <BaseTsd.h>
typedef SSIZE_T ssize_t;
# define _SSIZE_T_DEFINED
#endif

Happy to send a PR if you'd like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions