使用 g++-4 (Cygwin) 作为编译器的 Codeblocks 中的构建消息中的有趣字体

发布于 2024-12-07 20:01:10 字数 898 浏览 6 评论 0原文

我正在使用 CodeBlocks 10.05 和 Cygwin 1.7 来编译一些 C++ 代码。操作系统是WinXP SP3。使用的编译器是g++ 4.5.3。

当我构建以下程序时:

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
    unsigned long long a = 12345678901234;
    printf("%u\n",a);
    return 0;
}

它在构建日志中输出以下内容:

C:\Documents and Settings\Zhi Ping\Desktop\UVa\143\main.cpp||In function ‘int main()’:|
C:\Documents and Settings\Zhi Ping\Desktop\UVa\143\main.cpp|9|warning: format ‘%u’ expects type ‘unsigned int’, but argument 2 has type ‘long long unsigned int’|
C:\Documents and Settings\Zhi Ping\Desktop\UVa\143\main.cpp|9|warning: format ‘%u’ expects type ‘unsigned int’, but argument 2 has type ‘long long unsigned int’|
||=== Build finished: 0 errors, 2 warnings ===|

我不知道为什么 CodeBlocks 打印 ' 等符号。有没有办法让CodeBlocks正确显示字符?

I am using CodeBlocks 10.05 with Cygwin 1.7 to compile some C++ codes. The operating system is WinXP SP3. The compiler used is g++ 4.5.3.

When I build the following program:

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
    unsigned long long a = 12345678901234;
    printf("%u\n",a);
    return 0;
}

it outputs the following in the build log:

C:\Documents and Settings\Zhi Ping\Desktop\UVa\143\main.cpp||In function ‘int main()’:|
C:\Documents and Settings\Zhi Ping\Desktop\UVa\143\main.cpp|9|warning: format ‘%u’ expects type ‘unsigned int’, but argument 2 has type ‘long long unsigned int’|
C:\Documents and Settings\Zhi Ping\Desktop\UVa\143\main.cpp|9|warning: format ‘%u’ expects type ‘unsigned int’, but argument 2 has type ‘long long unsigned int’|
||=== Build finished: 0 errors, 2 warnings ===|

I do not know why CodeBlocks prints the ‘ etc. symbols. Is there a way for CodeBlocks to properly display the characters?

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

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

发布评论

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

评论(2

几味少女 2024-12-14 20:01:10

Cygwin 默认使用 UTF-8 编码,而 CodeBlocks 似乎假定输出采用 CP1252。此外,由于 Cygwin 告诉它 UTF-8 可用,因此 gcc 使用单独的左右版本的引号字符,而不是通常的 ASCII 版本。结果就是你所看到的。有两种方法可以解决这个问题:要么告诉 CodeBlocks 使用 UTF-8,要么通过设置 LANG=C 告诉 gcc 坚持使用 ASCII。但我不知道如何在 CodeBlocks 中执行这些操作。

Cygwin defaults to the UTF-8 encoding, whereas it looks like CodeBlocks assumes that output is in CP1252. Furthermore, since Cygwin tells it that UTF-8 is available, gcc uses separate left and right versions of quote characters instead of the usual ASCII ones. The result is what you're seeing. There are two ways to tackle this: either tell CodeBlocks to use UTF-8, or tell gcc to stick to ASCII by setting LANG=C. I don't know how to do either of these in CodeBlocks though.

没有心的人 2024-12-14 20:01:10

将以下环境变量添加到您的计算机:

LANG=C

在 Windows 7 中,您可以通过转至计算机 > 来添加它。属性>高级系统设置>环境变量,然后“新建...”。 Windows XP 中的菜单应该类似。

我希望可以回答一个老问题。今天我也遇到了这种情况,我花了一段时间才修复它。

Add the following Environment Variable to your computer:

LANG=C

In Windows 7, you can add it by going to Computer > Properties > Advanced System Settings > Environment Variables, then "New...". The menus should be similar in Windows XP.

I hope it's ok to answer an old question. This happened to me today as well, and it took me a while to fix it.

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