如何获取 C++ 的 FileHandle iostream?

发布于 2024-12-15 10:53:25 字数 131 浏览 6 评论 0原文

我需要在 Windows 上使用 mingw 与 C++ iostream 关​​联的 Windows FileHandle。这可能与 Windows 上与 C++ iostream 关​​联的 UNIX 文件描述符相同。有谁知道如何找到它?谢谢。

I need the Windows FileHandle associated with a C++ iostream using mingw on Windows. This is probably the same as the UNIX File Descriptor associated with a C++ iostream on Windows. Does anyone know how to find it? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国产ˉ祖宗 2024-12-22 10:53:25

您在这里看到我的答案了吗:
如何刷新 stdlib 输出文件在 win32 上?

std::basic_filebuf<char> *file_buf = dynamic_cast<std::basic_filebuf<char> *>(f.rdbuf());
if (file_buf != 0) {
    struct to_get_protected_member : public std::basic_filebuf<char> {
        int fd() { return _M_file.fd(); }
    };
    printf("your fd is %d\n", static_cast<to_get_protected_member *>(file_buf)->fd());
}

Did you see my answer, here:
How do I flush a stdlib output file on win32?

std::basic_filebuf<char> *file_buf = dynamic_cast<std::basic_filebuf<char> *>(f.rdbuf());
if (file_buf != 0) {
    struct to_get_protected_member : public std::basic_filebuf<char> {
        int fd() { return _M_file.fd(); }
    };
    printf("your fd is %d\n", static_cast<to_get_protected_member *>(file_buf)->fd());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文