Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#7,286 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
c

调研方向

从 git2/sys/stream.h 中的公共声明开始,并将其类型处理方式与 src/util/win32/msvc-compat.h 中的内部定义进行比较。使用 MSVC 或 clang-cl consumer 验证该 header,然后确认包含它能够提供 ssize_t,且不会破坏其他平台,同时确认 stream callback 声明可以成功编译。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C
星标
10.6k
派生
2.7k
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

libgit2/libgit2 的其他 Issue

查看 libgit2/libgit2 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。