【问题标题】:OracleSolaris 11.2 -- simple file I/O, cc warningOracleSolaris 11.2 -- 简单文件 I/O、cc 警告
【发布时间】:2015-07-09 14:35:19
【问题描述】:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(void)
{
  int fd;
  fd = open("abc.txt", O_RDONLY);
  if (fd < 0)
  {
    exit(EXIT_FAILURE);
  }

  printf("fd %d\n", fd);
  close(fd);

  exit(EXIT_SUCCESS);  
}

现在我构建它:

$ cc -errwarn=%all -o ~/tmp/aa ~/tmp/a.c
warning: bad message tag: /export/home/rmashak/tmp/a.call
$ cc -V
cc: Sun C 5.12 SunOS_i386 2011/11/16

它确实执行得很好,但是警告是什么?

【问题讨论】:

标签: file-io solaris opensolaris


【解决方案1】:

我没有足够的声誉来添加评论...这看起来确实像解析器的编译器错误。用更高版本的cc编译不会产生这个错误。

$ cc -V                                 
cc: Sun C 5.13 SunOS_i386 2014/10/20
$ cc -errwarn=%all -o ~/tmp/aa ~/tmp/a.c
$ 

在您的输出中,cc 似乎已将源文件名与“-errwarn”标签“all”的其余部分连接起来,奇怪!

【讨论】:

    【解决方案2】:

    错误意味着您向 -errwarn 传递了一个无法识别的选项:

    % cc -errwarn=%mumblefrotz -o hello hello.c
    warning: bad message tag: %mumblefrotz
    

    您的 shell 似乎以某种方式将命令中的 % 转换为 /export/home/rmashak/tmp/a.c,然后再将其传递给编译器。看起来像 zsh 之类的一些 shell 可能会在命令处理中专门扩展 % 标志 - 检查文档以了解您使用的任何 shell。

    如果您使用的是最新版本的 Solaris Studio,% 是可选的以避免此类问题 - 您可以将命令更改为:

    cc -errwarn=all -o ~/tmp/aa ~/tmp/a.c
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-28
      • 2018-06-29
      • 2011-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多