我正在使用Cygwin1.7的CodeBlocks 10.05来编译一些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正确显示字符?
发布于 2011-10-02 16:20:16
CP1252默认使用UTF-8编码,而看起来CodeBlocks假定输出是Cygwin格式的。此外,由于Cygwin告诉它UTF-8是可用的,所以gcc使用单独的左右版本的引号字符,而不是通常的ASCII字符。结果就是你所看到的。有两种方法可以解决这个问题:要么告诉CodeBlocks使用UTF8,要么通过设置LANG=C来告诉gcc坚持使用ASCII码。不过,我不知道如何在CodeBlocks中做这两件事。
发布于 2014-02-27 05:36:04
将以下环境变量添加到您的计算机:
LANG=C在Windows7中,你可以通过进入“电脑”>“属性”>“高级系统设置”>“环境变量”,然后“新建...”来添加它。在Windows XP中,菜单应该类似。
我希望可以回答一个老问题。这也发生在我今天,我花了一段时间来解决它。
https://stackoverflow.com/questions/7620496
复制相似问题