有誰知道GNU GCC中libstdC++中basic_filebuf的默認緩衝區大小嗎?我知道成員函數pubsetbuf(),我很確定緩衝區大小是實現定義的。在C內部很簡單,從<cstdio>
處取BUFSIZ。libstdC++中basic_filebuf的默認緩衝區大小
也許變量被稱爲extern_buf,XSIZE,intern_buf或ISIZE?
有誰知道GNU GCC中libstdC++中basic_filebuf的默認緩衝區大小嗎?我知道成員函數pubsetbuf(),我很確定緩衝區大小是實現定義的。在C內部很簡單,從<cstdio>
處取BUFSIZ。libstdC++中basic_filebuf的默認緩衝區大小
也許變量被稱爲extern_buf,XSIZE,intern_buf或ISIZE?
我找到了。 C++從C中獲取BUFSIZ(請參閱參考資料)。文件fstream和fstream.tcc包括類別basic_filebuf。
注:++的libstdc從GCC
從文件fstream.tcc文件fstream的
#include <istream>
#include <ostream>
#include <bits/codecvt.h>
#include <cstdio> // For BUFSIZ
#include <bits/basic_file.h> // For __basic_file, __c_lock
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <string> // For std::string overloads.
#endif
/**
* Actual size of internal buffer. This number is equal to the size
* of the put area + 1 position, reserved for the overflow char of
* a full area.
*/
size_t _M_buf_size;
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock),
_M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(),
_M_state_last(), _M_buf(0), _M_buf_size(BUFSIZ),
_M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(),
_M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
_M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0),
_M_ext_end(0)
{
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
}
8千字節
它可能會因實現而有所不同。由於我開始了一個新的個人項目,我對此很好奇。因爲彼得的回答,我的搜索開始於stdio.h
。一個簡單的:
cat /usr/include/stdio.h | grep -i bufsiz
產生了重新定義。
grep -rwnl /usr/include/ -e
_IO_BUFSIZ
第一(在libio.h
定義)被追加,然後_G_BUFSIZ
(在_G_config.h
定義)。重新定義停在那裏。
grep -i _g_bufsiz /usr/include/_G_config.h
我開了頭的basic_filebuf,並看看你,默認值是,哦,有什麼新的閃亮的按鈕,是這樣嗎? – PlasmaHH 2012-04-27 12:46:50
到目前爲止你是對的。謝謝!但也有點不禮貌。老實說。我只是沒有找到正確的文件來看看裏面。認爲它不能是fstream/fstream.tcc,因爲我查看了「basic_filebuf」的alwas!但正是這個文件,我必須看! – Peter 2012-04-27 13:39:20