Public header git2/sys/stream.h uses ssize_t, undefined for MSVC/clang-cl consumers
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- c
- 领域
- api, operating-systems
调研方向
从 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
libgit2/libgit2 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 4/5 3-5 天 新手友好度 68/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
kovidgoyal/kitty#10516 ·
-
libc
难度 2/5 1-2 天 新手友好度 76/100
llvm/llvm-project#225506 · 1 条评论 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 88/100
-
Status: Waiting triage Type: Bug
难度 2/5 1-3 小时 新手友好度 84/100
nanoframework/Home#1857 ·
-
bug
难度 2/5 半天 新手友好度 82/100