Cross-platform and major safety update!
Recommended for all users, especially those who need macOS/Linux support.
Changelog
-
For both C and C++ versions:
- Added cross-platform support for restoring standard streams.
- Changed all functions to
static inline, improving header safety in multi-file projects while keeping objects in each source file independent.
-
For the C++ version
cfs.hpp:- Added support for passing
nullptrto thecfsfunction in C++11 and later. Its usage is the same asNULL, andNULLremains fully compatible.
- Added support for passing
-
For the C version
cfs.h:- Added a C99 or later standard check.
Notes
- Cross-platform standard stream restoration is designed for restoring the system terminal, including environments such as CLion Terminal.
- Some IDE-managed run consoles may not provide a real terminal device, so the restoration feature may not work as expected in those environments.
- Since standards earlier than C99 are rarely used today, including this header in a C project below C99 will now produce a compile-time error. Please switch to C99 or later, or use an older version of
cfs, such asV1.2.0.
跨平台与重大安全更新!
推荐所有用户(特别是需要 macOS/Linux 支持的用户)更新
更新日志
-
C 与 C++ 版本。
- 添加跨平台标准流恢复支持。
- 所有函数统一改为
static inline,提升多源文件项目中的头文件安全性,同时保持每个源文件中的对象相互独立。
-
对于 C++ 版本
cfs.hpp。- 对于 C++11 及以上标准,添加了
cfs函数参数中对nullptr的支持,用法与NULL相同且兼容NULL。
- 对于 C++11 及以上标准,添加了
-
对于 C 版本
cfs.h。- 添加 C99 及以上标准检查。
注意事项
- 跨平台标准流恢复功能适用于恢复系统终端,也包括 Clion Terminal 等。但某些 IDE 托管的运行控制台可能不提供真实终端设备,因此目前可能无法实现相应效果。
- 考虑到 C99 以下标准使用人数少,现在 C99 以下版本包含本头文件将会报错,请切换到 C99 及以上版本或使用旧版
cfs如V1.2.0