QtCreator:大量杂散错误

发布于 2024-10-16 06:19:46 字数 603 浏览 2 评论 0原文

该项目运行良好,运行良好,编译良好。直到某个看似随机的时间,情况不再好转。

目前我遇到了大约 200 个杂散错误:

./new:4: error: stray '\376' in program
./new:4: error: stray '\377' in program
./new:5: error: stray '\376' in program
./new:5: error: stray '\377' in program

通过阅读其他帖子,我的代码中似乎有一些我看不到的坏字符。所以我清空了我正在处理的整个文件,但没有运气。无论我做什么,这个错误仍然存​​在。

此外,在编译 main.cpp 时(它首先执行此操作),它首先包含 #include,它是“来自“文件””消息链的开始。这意味着它还没有真正解析 main.cpp 的大部分内容,但会因为读取内部 Qt 文件而感到厌烦。

我完全在黑暗中凝视着这里,这可能是什么,我该如何解决这个问题?

我使用的是 Qt 4.7.2、GCC 4.5.0 和 Windows 7。

The project was doing fine, running fine, compiling fine. Until some seemingly random time it stopped being fine.

At the moment I'm getting around 200 stray errors:

./new:4: error: stray '\376' in program
./new:4: error: stray '\377' in program
./new:5: error: stray '\376' in program
./new:5: error: stray '\377' in program

From reading other posts it seems I have some bad characters in my code which I cannot see. So I emptied the whole file I was working on, but no luck. This error persists whatever I do.

Also, when compiling main.cpp (which it does first), it first and foremost includes #include <QApplication>, which is the start of the chain of "from 'file'" messages. This means it didn't really parsed much of main.cpp yet, but gets borked from reading internal Qt files.

I'm totally gazing in the dark here, what could this possible be, and how would I resolve this?

I'm using Qt 4.7.2, GCC 4.5.0 and Windows 7.

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

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

发布评论

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

评论(5

指尖上的星空 2024-10-23 06:19:46

八进制 \376 \3770xFEFF,即 Unicode 字节顺序标记。它用于表示 UTF-16 文本文件的字节顺序,也用于表示文件是 UTF-8 编码的。它应该只出现在文件的开头,但它似乎已经渗入库头文件 new 的头注释中,位于第 4 行和第 5 行。找到该文件,然后删除这些行。 (但前提是它们是评论!)

Octal \376 \377 is 0xFEFF, which is the Unicode Byte-Order Mark. It is used to signal the endianness of a UTF-16 text file, and also to signal that a file is UTF-8-encoded. It should only occur at the start of a file, but it seems to have crept into the header comments in your library header file new, at lines 4 and 5. Locate this file, and delete those lines. (But only if they're comments!)

你对谁都笑 2024-10-23 06:19:46

将代码复制到记事本中并保存。然后删除 main.cpp 并将记事本添加到您的项目中。重建并检查结果。

如果它仍然存在,那么问题很可能不在于您的源代码,而在于 Qt 或 gcc 和/或 gnulibc 库。它们可能已损坏或以不同的、不受支持的编码存储。

Copy your code into Notepad and save it. Then remove your main.cpp and add the Notepad one to your project. Rebuild and check the result.

If it still persists then most probably the problem is not with your source, but with the Qt or gcc and/or gnulibc libraries. They probably got corrupted or are stored in a different, unsupported encoding.

乱了心跳 2024-10-23 06:19:46

您的源文件可能采用 UTF-16 或类似格式编码。

尝试将代码复制粘贴到新文件中,看看是否有帮助。

Your source file is probably encoded in UTF-16 or something like that.

Try copy-pasting the code in a new file and see if that helps.

绝影如岚 2024-10-23 06:19:46

对我来说,当我从某个网页复制源代码时,类似的事情就发生过。

只有再次输入才能解决问题。但也许一些转换编码的工具也可以解决这个问题。

To me things like these happened in the past when I copied source from some web page.

Only typing it again solved the issue. But maybe some tool to convert the encoding might fix the issue as well.

情场扛把子 2024-10-23 06:19:46

可能存在冲突。例如,我创建了一个名为 QTcpServer.pro 的项目,但是当我尝试 #include QTcpServer 时,我遇到了许多杂散错误。重命名我的项目(QTcpSvr.pro)解决了这个错误。

A conflict might exist. For example, I created a project named QTcpServer.pro, but when I tried to #include QTcpServer, I got many stray errors. Renaming my project (QTcpSvr.pro) solved this error.

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