You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何我的C++编译器输出构建信息时显示乱码字符?

CodeBlocks搭配GCC编译时构建信息乱码问题

使用CodeBlocks IDE搭配GNU GCC Compiler编译项目时,构建输出中出现乱码字符(示例如下),项目可正常编译,但乱码影响错误信息阅读。更换电脑后出现此问题,同课程其他同学无类似情况,怀疑是否缺少Windows语言包?

||=== Build: Debug in prac4e2 (compiler: GNU GCC Compiler) ===|
C:\Users\...\producto.cpp||In function ‘void CargarProducto(Producto&)’:|
C:\Users\...\producto.cpp|8|warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long int*’ [-Wformat=]|
C:\Users\...\producto.cpp||In function ‘void MostrarProducto(Producto)’:|
C:\Users\...\producto.cpp|28|warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]|
||=== Build finished: 0 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
||=== Run: Debug in prac4e2 (compiler: GNU GCC Compiler) ===|

解决方法

  • 调整CodeBlocks编码设置:打开CodeBlocks,依次进入Settings -> Editor -> General settings,在Encoding下拉菜单中选择UTF-8或Windows-1252,应用设置后重启IDE尝试。
  • 检查系统区域语言设置:打开控制面板的「区域」设置,切换到「管理」标签页,查看「非Unicode程序的语言」,确保设置为与系统匹配的语言(如中文简体或英文),更改后重启电脑。
  • 指定GCC输出编码:编译时添加参数-fexec-charset=GBK或-fexec-charset=UTF-8,强制GCC输出对应编码的信息,适配CodeBlocks的显示。

内容的提问来源于stack exchange,提问作者Maxi Fernandez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 06:42:14