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

发布于 2024-11-28 22:16:27 字数 1982 浏览 2 评论 0 原文

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

但我不断收到以下错误。该程序还具有命令行参数 -f path 在给定路径读取文件(例如/some/where/nmea.txt) 我应该更改什么来运行该程序?我收到的错误是由于编译器问题吗?因为我把 cygwin、MinGW 编译器添加到 eclipse 搞砸了!我知道程序是正确的。其他人已经使用它并得到了结果。(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

I'm trying to execute this code nmea2kml.cpp

but I keep getting the following errors. Also the program has command line parameters -f path Read file at given path (e.g. /some/where/nmea.txt) What should I change to run the program? Am I getting the error due to a compiler problem? coz I've messed up with adding cygwin, MinGW compilers to eclipse!! I know the program is correct. Others have used it and got the results.(http://julien.cayzac.name/code/gps/)

Error

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

a√萤火虫的光℡ 2024-12-05 22:16:27

看起来你已经写了 std::cerr < “...”< 运算符),您要在其中写入 std::cerr << “...”<< 运算符)。

It looks like you have written std::cerr < "..." (the < operator) where you meant to write std::cerr << "..." (the << operator).

巨坚强 2024-12-05 22:16:27

尝试使用位移位“<<”而不是小于号“<”与您的 ostream 的运算符:

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

Try using the bit-shift "<<" instead of the less-than "<" operator with your ostreams:

std::cerr << "Converting file \"";
多情出卖 2024-12-05 22:16:27

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

No, the code as shown is not correct. You perform output with std::cout << ..., not std::cout < .... Probably some HTML conversion messed it up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文