【问题标题】:gcc error message includes unnecessary charactergcc 错误消息包含不必要的字符
【发布时间】:2021-11-10 21:36:00
【问题描述】:

我刚刚写了一个很简单的c文件。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>

int main(int argc, char *argv[])
{
   int sock = -1;

   /* open raw socket */
   sock = socket(PF_PACKET, SOCK_RAW, 0);
   if (sock == -1)
   {
      printf("socket creation failed\n");
      return -1;
   }

   /* receive packets */

   /* close raw socket */
   close(sock);

   return 0;
}

并尝试使用命令“gcc packet_receive.c”进行编译 然后,我收到如下错误消息。

$ gcc packet_receive.c
packet_receive.c: In function emainf:
packet_receive.c:22:2: warning: implicit declaration of function eclosef; did you mean epclosef? [-Wimplicit-function-declaration]
  close(sock);
  ^~~~~
  pclose

我明白为什么我会看到这个错误。 但我想知道为什么我在错误消息中的 main、close、pclose 前面看到“e”。

有没有人看到相同类型的错误消息?

【问题讨论】:

  • 有趣。尝试一些不同的控制台?可能是一些转义码被奇怪地解释了
  • 'e' 和 'f' 应该是引号字符,例如emainf 应该是 'main'。显然,编译器使用 unicode 字符作为引号,而终端没有将它们显示为 unicode。
  • 我投票结束这个问题,因为 mojibake。见自我回答。没有必要再添加了。

标签: c linux gcc message centos8


【解决方案1】:

感谢 cmets。 我正在使用 teraterm 并且不小心将语言环境设置为日语。 当我将语言环境设置为美国时,问题就解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-27
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2011-07-25
    • 1970-01-01
    • 2021-11-17
    相关资源
    最近更新 更多