由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++ problem
相关主题
fstream 扫盲,谢谢!读取数据求教
请问一个入门级 dynamic memory 的问题关于文件读取的C++ 问题?
一个极简单的程序求教a very simple c++ question
c++ template中如何判断类型What is wrong with the code?
ofstream and cout question问一个C++文件读取的问题
Why no output file generate? What is wrong?how to read a sentence into a vector of string?
ostream& operator << (ostream& s, int cnt) errorC++ Q 99-102 (转载)
C++: Static initialization dependency能否对某个库进行操作符重载?
相关话题的讨论汇总
话题: std话题: cygwin话题: usr话题: gcc话题: lib
进入Programming版参与讨论
1 (共1页)
x******a
发帖数: 6336
1
I got thousands problems on the following piece of code "dumpfile.h" when I
compile under cygwin. it is ok under visual stduio... can anyone help?
Thanks!
#include
#include
#include //ostream_iterator
#include //cerr
#include //std::copy
template
void dump_to_file(const char* filename, const std::vector& v_d){
std::ofstream ofs(filename);
if(!ofs){
std::cerr<<"Unable to open the file to write!n";
return ;
}
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
ofs.close();
}
$ make
g++ -g -std=c++11 -pedantic -I /usr/local/include/ -Wall -o IRC.exe main.cpp
-L /usr/local/lib/ -l libboost_regex
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:40:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/codecvt.h:485:61: error
_facet(const std::locale&) [with _Facet = std::
std::codecvt]’ in namespace ‘std::std’ (which
does not e nclose
namespace ‘std’) [-fpermissive]
use_facet >(const locale&);
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/codecvt.h:489:61: error
nst std::locale&) [with _Facet = std::std::
codecvt]’ in namespace ‘std::std’ (which does not
enclose na mespace ‘
std’) [-fpermissive]
has_facet >(const locale&);
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/codecvt.h:496:64: error
_facet(const std::locale&) [with _Facet = std::
std::codecvt]’ in namespace ‘std::std’ (which
does no t enclose
namespace ‘std’) [-fpermissive]
use_facet >(const locale&);
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/codecvt.h:500:64: error
nst std::locale&) [with _Facet = std::std::
codecvt]’ in namespace ‘std::std’ (which does
not enclose namespace
‘std’) [-fpermissive]
has_facet >(const locale&);
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:41:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:99:11: error: ‘::
fpos_t’ has not been declared
using ::fpos_t;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:101:11: error: ‘::
clearerr’ has not been declared
using ::clearerr;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:102:11: error: ‘::
fclose’ has not been declared
using ::fclose;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:103:11: error: ‘::
feof’ has not been declared
using ::feof;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:104:11: error: ‘::
ferror’ has not been declared
using ::ferror;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:105:11: error: ‘::
fflush’ has not been declared
using ::fflush;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:106:11: error: ‘::
fgetc’ has not been declared
using ::fgetc;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:107:11: error: ‘::
fgetpos’ has not been declared
using ::fgetpos;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:108:11: error: ‘::
fgets’ has not been declared
using ::fgets;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:109:11: error: ‘::
fopen’ has not been declared
using ::fopen;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:110:11: error: ‘::
fprintf’ has not been declared
using ::fprintf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:111:11: error: ‘::
fputc’ has not been declared
using ::fputc;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:112:11: error: ‘::
fputs’ has not been declared
using ::fputs;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:113:11: error: ‘::
fread’ has not been declared
using ::fread;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:114:11: error: ‘::
freopen’ has not been declared
using ::freopen;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:115:11: error: ‘::
fscanf’ has not been declared
using ::fscanf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:116:11: error: ‘::
fseek’ has not been declared
using ::fseek;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:117:11: error: ‘::
fsetpos’ has not been declared
using ::fsetpos;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:118:11: error: ‘::
ftell’ has not been declared
using ::ftell;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:119:11: error: ‘::
fwrite’ has not been declared
using ::fwrite;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:120:11: error: ‘::
getc’ has not been declared
using ::getc;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:121:11: error: ‘::
getchar’ has not been declared
using ::getchar;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:124:11: error: ‘::
gets’ has not been declared
using ::gets;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:126:11: error: ‘::
perror’ has not been declared
using ::perror;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:127:11: error: ‘::
printf’ has not been declared
using ::printf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:128:11: error: ‘::
putc’ has not been declared
using ::putc;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:129:11: error: ‘::
putchar’ has not been declared
using ::putchar;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:130:11: error: ‘::
puts’ has not been declared
using ::puts;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:131:11: error: ‘::
remove’ has not been declared
using ::remove;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:132:11: error: ‘::
rename’ has not been declared
using ::rename;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:133:11: error: ‘::
rewind’ has not been declared
using ::rewind;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:134:11: error: ‘::
scanf’ has not been declared
using ::scanf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:135:11: error: ‘::
setbuf’ has not been declared
using ::setbuf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:136:11: error: ‘::
setvbuf’ has not been declared
using ::setvbuf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:137:11: error: ‘::
sprintf’ has not been declared
using ::sprintf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:138:11: error: ‘::
sscanf’ has not been declared
using ::sscanf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:139:11: error: ‘::
tmpfile’ has not been declared
using ::tmpfile;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:141:11: error: ‘::
tmpnam’ has not been declared
using ::tmpnam;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:143:11: error: ‘::
ungetc’ has not been declared
using ::ungetc;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:144:11: error: ‘::
vfprintf’ has not been declared
using ::vfprintf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:145:11: error: ‘::
vprintf’ has not been declared
using ::vprintf;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cstdio:146:11: error: ‘::
vsprintf’ has not been declared
using ::vsprintf;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:282:23: error: ‘
string’ in namespace ‘std::std’ does not name a type
open(const std::string& __s, ios_base::openmode __mode)
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream: In member function
‘std::std::basic_filebuf<_CharT, _Traits>::__filebu
f_type* std::std::basic_filebuf<_CharT, _Traits
>::open(const int&, std::ios_base::openmode)’:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:283:25: error:
request for member ‘c_str’ in ‘__s’, which is of non-cla
ss type ‘const int’
{ return open(__s.c_str(), __mode); }
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream: At global scope:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:486:33: error: ‘
string’ in namespace ‘std::std’ does not name a type
basic_ifstream(const std::string& __s,
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:561:23: error: ‘
string’ in namespace ‘std::std’ does not name a type
open(const std::string& __s, ios_base::openmode __mode = ios_base::in)
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:661:33: error: ‘
string’ in namespace ‘std::std’ does not name a type
basic_ofstream(const std::string& __s,
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:737:23: error: ‘
string’ in namespace ‘std::std’ does not name a type
open(const std::string& __s,
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:834:32: error: ‘
string’ in namespace ‘std::std’ does not name a type
basic_fstream(const std::string& __s,
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:910:23: error: ‘
string’ in namespace ‘std::std’ does not name a type
open(const std::string& __s,
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc: In member
function ‘virtual std::std::basic_filebuf<_CharT, _
Traits>::int_type std::std::basic_filebuf<_
CharT, _Traits>::underflow()’:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:311:18:
error: ‘min’ is not a member of ‘std::std’
__ilen = std::min(__avail, __buflen);
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:311:18:
note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
algorithm:62:0,
from /usr/local/include/boost/random/additive_combine.hpp:
21,
from /usr/local/include/boost/random.hpp:36,
from rng2.h:8,
from main.cpp:4:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/stl_algo.h:3444:5: note
min(initializer_list<_Tp> __l, _Compare __comp)
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc: In member
function ‘virtual std::streamsize std::std::basic_f
ilebuf<_CharT, _Traits>::xsputn(const _CharT*,
std::streamsize)’:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:657:31:
error: ‘min’ is not a member of ‘std::std’
const streamsize __limit = std::min(__chunk, __bufavail);
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:657:31:
note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
algorithm:62:0,
from /usr/local/include/boost/random/additive_combine.hpp:
21,
from /usr/local/include/boost/random.hpp:36,
from rng2.h:8,
from main.cpp:4:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/stl_algo.h:3444:5: note
min(initializer_list<_Tp> __l, _Compare __comp)
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc: At global
scope:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:968:43:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_filebuf;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:72:11: error:
provided for ‘template class
std::std::basic_filebuf’
class basic_filebuf : public basic_streambuf<_CharT, _Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:969:44:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_ifstream;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:430:11: error:
provided for ‘template clas
s std::std::basic_ifstream’
class basic_ifstream : public basic_istream<_CharT, _Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:970:44:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_ofstream;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:602:11: error:
provided for ‘template clas
s std::std::basic_ofstream’
class basic_ofstream : public basic_ostream<_CharT,_Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:971:43:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_fstream;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:779:11: error:
provided for ‘template clas
s std::std::basic_fstream’
class basic_fstream : public basic_iostream<_CharT, _Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:974:46:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_filebuf;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:72:11: error:
provided for ‘template class
std::std::basic_filebuf’
class basic_filebuf : public basic_streambuf<_CharT, _Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:975:47:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_ifstream;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:430:11: error:
provided for ‘template clas
s std::std::basic_ifstream’
class basic_ifstream : public basic_istream<_CharT, _Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:976:47:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_ofstream;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:602:11: error:
provided for ‘template clas
s std::std::basic_ofstream’
class basic_ofstream : public basic_ostream<_CharT,_Traits>
^
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
fstream:939:0,
from dumpfile.h:5,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/fstream.tcc:977:46:
error: wrong number of template arguments (1, should b
e 2)
extern template class basic_fstream;
^
In file included from dumpfile.h:5:0,
from main.cpp:8:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/fstream:779:11: error:
provided for ‘template clas
s std::std::basic_fstream’
class basic_fstream : public basic_iostream<_CharT, _Traits>
^
In file included from main.cpp:8:0:
dumpfile.h:10:52: error: ‘vector’ in namespace ‘std::std’ does not name
a template type
void dump_to_file(const char* filename, const std::vector& v_d){
^
dumpfile.h:10:58: error: expected ‘,’ or ‘...’ before ‘<’ token
void dump_to_file(const char* filename, const std::vector& v_d){
^
dumpfile.h: In function ‘void std::dump_to_file(const char*, int)’:
dumpfile.h:11:2: error: ‘ofstream’ is not a member of ‘std::std’
std::ofstream ofs(filename);
^
dumpfile.h:11:2: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/ios:38
from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
ostream:38,
from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
iostream:39,
from main.cpp:3:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/iosfwd:160:34: note: ‘std
typedef basic_ofstream ofstream;
^
In file included from main.cpp:8:0:
dumpfile.h:12:6: error: ‘ofs’ was not declared in this scope
if(!ofs){
^
dumpfile.h:13:9: error: ‘cerr’ is not a member of ‘std::std’
std::cerr<<"Unable to open the file to write!n";
^
dumpfile.h:13:9: note: suggested alternative:
In file included from main.cpp:3:0:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/iostream:62:18: note: ‘
std::cerr’
extern ostream cerr; /// Linked to standard error (unbuffered)
^
In file included from main.cpp:8:0:
dumpfile.h:16:2: error: ‘copy’ is not a member of ‘std::std’
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
^
dumpfile.h:16:2: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/
locale_facets.h:48:0,
from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/
basic_ios.h:37,
from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/ios:44,
from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
ostream:38,
from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
iostream:39,
from main.cpp:3:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/streambuf_iterator.h:
293:5: note: ‘std::copy’
copy(istreambuf_iterator<_CharT> __first,
^
In file included from main.cpp:8:0:
dumpfile.h:16:12: error: ‘v_d’ was not declared in this scope
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
^
dumpfile.h:16:36: error: ‘ostream_iterator’ is not a member of ‘std::std’
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
^
dumpfile.h:16:36: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/
iterator:66:0,
from /usr/local/include/boost/random/lagged_fibonacci.hpp:
23,
from /usr/local/include/boost/random.hpp:40,
from rng2.h:8,
from main.cpp:4:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/stream_iterator.h:154:
11: note: ‘std::ostream_iterator’
class ostream_iterator
^
In file included from main.cpp:8:0:
dumpfile.h:16:59: error: expected primary-expression before ‘>’ token
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
^
dumpfile.h:16:61: error: ‘ofs’ was not declared in this scope
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
^
dumpfile.h: At global scope:
dumpfile.h:21:41: error: ‘std::std::vector’ has not been declared
void dump_to_file(const char* ofs, std::vector > arr)
^
dumpfile.h:21:47: error: expected ‘,’ or ‘...’ before ‘<’ token
void dump_to_file(const char* ofs, std::vector > arr)
^
dumpfile.h:21:6: error: redefinition of ‘template void std::dump_
to_file(const char*, int)’
void dump_to_file(const char* ofs, std::vector > arr)
^
dumpfile.h:10:6: note: ‘template void std::dump_to_file(const char
*, int)’ previously declared here
void dump_to_file(const char* filename, const std::vector& v_d){
^
x******a
发帖数: 6336
2
a lot lines are
error: ‘***’ is not a member of ‘std::std’, *** is something such as
endl, string, etc.

I

【在 x******a 的大作中提到】
: I got thousands problems on the following piece of code "dumpfile.h" when I
: compile under cygwin. it is ok under visual stduio... can anyone help?
: Thanks!
: #include
: #include
: #include //ostream_iterator
: #include //cerr
: #include //std::copy
: template
: void dump_to_file(const char* filename, const std::vector& v_d){

N******K
发帖数: 10202
3
cygwin 头文件没有包含进去?

I

【在 x******a 的大作中提到】
: I got thousands problems on the following piece of code "dumpfile.h" when I
: compile under cygwin. it is ok under visual stduio... can anyone help?
: Thanks!
: #include
: #include
: #include //ostream_iterator
: #include //cerr
: #include //std::copy
: template
: void dump_to_file(const char* filename, const std::vector& v_d){

x******a
发帖数: 6336
4
If I compile separately with g++ -std=c++11. It works.
but if I use the following makefile, it does not work.
CPP = g++
CXXFLAGS = -std=c++11
#-pedantic
OFLAG = -Wall -o
LFLAG = -l
IFLAG = -I
LIBFLAG = -L
LIBDIR = /usr/local/lib/
INCLUDEDIR = /usr/local/include/
DEBUGF = -g -D DEBUG
DEBUG = no
.SUFFIXES: .exe .cpp
.cpp.exe:
$(CPP) $(OFLAG) $@ $<
$@
main.exe: main.cpp
$(CPP) $(CXXFLAGS) $(IFLAG) $(INCLUDEDIR) $(OFLAG) boost.exe main.cpp $(
LIBFLAG) $(LIBDIR) $(LFLAG) libboost_regex
d****i
发帖数: 4809
5
Must be some errors in your Makefile.
I compiled using GCC 4.4 on CentOS without C++11 flag turned on. It returns
no error:
$ g++ -o dump dump.cpp
dump.cpp:
#include
#include //ostream_iterator
#include //cerr
#include //std::copy
template
void dump_to_file(const char* filename, const std::vector& v_d){
std::ofstream ofs(filename);
if(!ofs){
std::cerr<<"Unable to open the file to write!n";
return ;
}
std::copy(v_d.begin(), v_d.end(), std::ostream_iterator(ofs, "n"));
ofs.close();
}
int main()
{
int data_array[] = {1, 2, 3, 4};
std::vector data(data_array, data_array+sizeof(data_array)/sizeof(
int));
dump_to_file("record.txt", data);
}

I

【在 x******a 的大作中提到】
: I got thousands problems on the following piece of code "dumpfile.h" when I
: compile under cygwin. it is ok under visual stduio... can anyone help?
: Thanks!
: #include
: #include
: #include //ostream_iterator
: #include //cerr
: #include //std::copy
: template
: void dump_to_file(const char* filename, const std::vector& v_d){

d****i
发帖数: 4809
6
Your Makefile doesn't obey the Makefile convention: You should use CC or CXX
in place of CPP, should be CFLAGS in place of OFLAG, should be LDFLAGS
instead of LFLAG, "-I" flag should be used in conjunction with -I${LOCAL_
INCLUDE_PATH}. rule target should be the object or executable file rather
than src file...

【在 x******a 的大作中提到】
: If I compile separately with g++ -std=c++11. It works.
: but if I use the following makefile, it does not work.
: CPP = g++
: CXXFLAGS = -std=c++11
: #-pedantic
: OFLAG = -Wall -o
: LFLAG = -l
: IFLAG = -I
: LIBFLAG = -L
: LIBDIR = /usr/local/lib/

1 (共1页)
进入Programming版参与讨论
相关主题
能否对某个库进行操作符重载?ofstream and cout question
fstream不能做类的成员吗Why no output file generate? What is wrong?
C++中怎么传递std::hex这样的参数啊ostream& operator << (ostream& s, int cnt) error
子类的assignment operator 怎么访问父类的private memberC++: Static initialization dependency
fstream 扫盲,谢谢!读取数据求教
请问一个入门级 dynamic memory 的问题关于文件读取的C++ 问题?
一个极简单的程序求教a very simple c++ question
c++ template中如何判断类型What is wrong with the code?
相关话题的讨论汇总
话题: std话题: cygwin话题: usr话题: gcc话题: lib