使用 g++-4 (Cygwin) 作为编译器的 Codeblocks 中的构建消息中的有趣字体
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.将以下环境变量添加到您的计算机:
在 Windows 7 中,您可以通过转至计算机 > 来添加它。属性>高级系统设置>环境变量,然后“新建...”。 Windows XP 中的菜单应该类似。
我希望可以回答一个老问题。今天我也遇到了这种情况,我花了一段时间才修复它。
Add the following Environment Variable to your computer:
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.