【 以下文字转载自 LinuxDev 讨论区 】
发信人: zhanghaoX (环顾四方有效), 信区: LinuxDev
标 题: 奇怪的问题: Debian的头文件 ?
发信站: 水木社区 (Thu Jun 18 16:10:10 2020), 站内
Debian10 编译一个C++程序 ,
const wchar_t* szFileName,
ofstream ofs;
ofs.open( szFileName , std::ios::out ) ;
报错:
error: no matching function for call to ‘std::basic_ofstream<char>::open(const wchar_t*&, const openmode&)’
ofs.open( szFileName , std::ios::out ) ;
^
In file included from /home/a/share/xxxx.cpp:9:
/usr/include/c++/8/fstream:851:7: note: candidate: ‘void std::basic_ofstream<_CharT, _Traits>::open(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]’
open(const char* __s, ios_base::openmode __mode = ios_base::out)
^~~~
/usr/include/c++/8/fstream:851:7: note: no known conversion for argument 1 from ‘const wchar_t*’ to ‘const char*’
/usr/include/c++/8/fstream:871:7: note: candidate: ‘void std::basic_ofstream<_CharT, _Traits>::open(const string&, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::__cxx11::string = std::__cxx11::basic_string<char>; std::ios_base::openmode = std::_Ios_Openmode]’
open(const std::string& __s, ios_base::openmode __mode = ios_base::out)
^~~~
/usr/include/c++/8/fstream:871:7: note: no known conversion for argument 1 from ‘const wchar_t*’ to ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’}
make[2]: *** [oooooo/CMakeFiles/oooooo.dir/build.make:102: oooooo/CMakeFiles/oooooo.dir/oooooo.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
头文件竟然没有 wchar_t* 的
/usr/include/c++/8/fstream:
/**
* @brief Opens an external file.
* @param __s The name of the file.
* @param __mode The open mode flags.
*
* Calls @c std::basic_filebuf::open(s,__mode|in). If that function
* fails, @c failbit is set in the stream's error state.
*/
void
open(const char* __s, ios_base::openmode __mode = ios_base::in)
{
if (!_M_filebuf.open(__s, __mode | ios_base::in))
this->setstate(ios_base::failbit);
else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 409. Closing an fstream should clear error state
this->clear();
}
#if __cplusplus >= 201103L
/**
* @brief Opens an external file.
* @param __s The name of the file.
* @param __mode The open mode flags.
*
* Calls @c std::basic_filebuf::open(__s,__mode|in). If that function
* fails, @c failbit is set in the stream's error state.
*/
void
open(const std::string& __s, ios_base::openmode __mode = ios_base::in)
{
if (!_M_filebuf.open(__s, __mode | ios_base::in))
this->setstate(ios_base::failbit);
else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 409. Closing an fstream should clear error state
this->clear();
}
#if __cplusplus >= 201703L
/**
* @brief Opens an external file.
* @param __s The name of the file, as a filesystem::path.
* @param __mode The open mode flags.
*
* Calls @c std::basic_filebuf::open(__s,__mode|in). If that function
* fails, @c failbit is set in the stream's error state.
*/
template<typename _Path>
_If_fs_path<_Path, void>
open(const _Path& __s, ios_base::openmode __mode = ios_base::in)
{ open(__s.c_str(), __mode); }
#endif // C++17
#endif // C++11
/**
* @brief Close the file.
*
* Calls @c std::basic_filebuf::close(). If that function
* fails, @c failbit is set in the stream's error state.
*/
void
close()
{
if (!_M_filebuf.close())
this->setstate(ios_base::failbit);
}
};
--
FROM 121.69.79.*
应该早支持了吧
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)
【 在 here080 (hero080) 的大作中提到: 】
: C++17才有支持吧?
: 之前linux上是char,windows才是wchar_t
--
FROM 121.69.79.*