我将一些代码移植到Darwin OS X,作为更改的一部分,我们从gcc转到clang编译器.
在代码中,有一个功能可追溯到2005年,并在互联网上发布了几个地方.它为几个不同的旧版GCC提供了功能,我已经删除了它提供的最后一个版本,v3.4.0或更高版本.代码取决于两个GCC特定类:__gnu_cxx::stdio_filebuf和__gnu_cxx::stdio_sync_filebuf.
//! Similar to fileno(3), but taking a C++ stream as argument instead of a
//! FILE*. Note that there is no way for the library to track what you do with
//! the descriptor, so be careful.
//! \return The integer file descriptor associated with the stream, or -1 if
//! that stream is invalid. In the latter case, for the sake of keeping the
//! code as similar to fileno(3), errno …Run Code Online (Sandbox Code Playgroud)