为什么我的 C++ 编译器在显示构建消息时会放置垃圾字符?

问题描述 投票:0回答:1
||=== 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) ===|

出于某种原因,编译器或我正在使用的程序只想显示这些字符而不是常规特殊字符。它编译得很好,而且我已经检查过编译器是否正确安装了两次,但是读起来很烦人,并且特别难以理解我可能遇到的任何错误。也许我缺少某种 Windows 语言包?

我使用的IDE是CodeBlocks。我同一大学课程的其他人没有这个问题,在我换电脑之前也没有这个问题。

c++ codeblocks
1个回答
0
投票

与使用 vim 的 ubuntuforums.org/showthread.php?t=2311239 类似,Code::Blocks 构建输出窗口看起来采用 ANSI 字符集(扩展 ASCII),而实际上它是 UTF-8。我不知道您是否可以将 Code::Blocks 编码设置为 UTF-8,将工具链的诊断日志设置为 ASCII/ANSI,但我认为其中之一是解决方案。当然你可以设置编辑器编码:设置->编辑器->常规设置->字体->默认编码。这也可能适用于诊断输出。

– 克利福德

© www.soinside.com 2019 - 2024. All rights reserved.