.cpp错误:'operator<'不匹配在'std :: cerr< “转换文件\”“'

时间:2011-08-08 04:28:07

标签: c++ compiler-errors nmea

我正在尝试执行此代码nmea2kml.cpp

但我一直收到以下错误。该程序还有命令行参数-f path Read file at given path (e.g. /some/where/nmea.txt)我应该更改什么来运行程序?我是否因编译问题而收到错误?因为我加入了cygwin,MinGW编译器来进行日食!我知道程序是正确的。其他人已经使用它并得到了结果。(http://julien.cayzac.name/code/gps/)

错误

g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\nmea.o ..\src\nmea.cpp
..\src\nmea.cpp: In function `int main(int, char**)':
..\src\nmea.cpp:195: error: no match for 'operator<' in 'std::cerr < "Converting file \""'
..\src\nmea.cpp:195: note: candidates are: operator<(const char*, const char*) <built-in>
..\src\nmea.cpp:195: note:                 operator<(void*, void*) <built-in>
..\src\nmea.cpp:336: error: no match for 'operator<' in 'std::cout < "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"'
..\src\nmea.cpp:336: note: candidates are: operator<(const char*, const char*) <built-in>
..\src\nmea.cpp:336: note:                 operator<(void*, void*) <built-in>
..\src\nmea.cpp:336: error: `std::endl(std::basic_ostream<_CharT, _Traits>&)' cannot appear in a constant-expression
..\src\nmea.cpp:355: error: parse error in template argument list
..\src\nmea.cpp:336: error: `endl<<expression error> >' cannot appear in a constant-expression
..\src\nmea.cpp:406: error: parse error in template argument list
..\src\nmea.cpp:336: error: `endl<<expression error> >' cannot appear in a constant-expression
..\src\nmea.cpp:406: error: parse error in template argument list
..\src\nmea.cpp:336: error: `endl<<expression error> >' cannot appear in a constant-expression
..\src\nmea.cpp:406: error: parse error in template argument list
..\src\nmea.cpp:406: error: expected `;' before '}' token
..\src\nmea.cpp:193: warning: unused variable 'outfile'
Build error occurred, build is stopped

3 个答案:

答案 0 :(得分:3)

看起来您已经写了std::cerr < "..."<运算符),您打算写std::cerr << "..."<<运算符)。

答案 1 :(得分:1)

尝试使用位移“&lt;&lt;”而不是小于“&lt;”操作员与你的ostreams:

std::cerr << "Converting file \"";

答案 2 :(得分:1)

不,显示的代码不正确。您使用std::cout << ...执行输出,而不是std::cout < ...。可能有些HTML转换搞砸了。