为什么 GCC 在 Ubuntu 10 中显得更加冗长?
我最近做了一个 cp 克隆(为大学),我碰巧发现了一些我从未有机会发现的东西。
这至少适用于 GCC 编译 C 源代码。
我在 Mac OS X (10.6.4) 中完成了这个特定 C 程序的主要开发,使用 Apple 的 /usr/bin/gcc --version
构建,
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Copyright (C) 2007 Free Software Foundation, Inc.
但是,我在 Arch Linux 中运行了测试Mac 中的虚拟机,带有最新的 gcc(没有添加,没有自定义,没有像 Apple 那样的 mods)
gcc (GCC) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
,我们必须在 Ubuntu 10.04.1 LTS 的类中构建它。
我的 Makefile 是这样的:
CC=gcc
#CFLAGS=-O0 -g -Wall
CFLAGS=-O3 -Wall -finline-functions
EXE=copy
compile:
$(CC) $(CFLAGS) -o $(EXE) main.c
所以,我总是在启用 -Wall
的情况下运行(在每个操作系统中)gcc。 Mac和Arch从未表现出任何警告。
Ubuntu 打印了两个警告,有 和没有 -Wall
do_copy.c: In function 'do_copy_file2file':
do_copy.c:27: warning: ignoring return value of 'realpath', declared with attribute warn_unused_result
do_copy.c: In function 'do_copy_symlink2file':
do_copy.c:117: warning: ignoring return value of 'symlink', declared with attribute warn_unused_result
Ubuntu 的 GCC 版本是该发行版的默认版本: gcc (Ubuntu 4.4.3-ubuntu5) 4.4.3
为什么会发生这种情况?
为什么我在其他两个操作系统中看不到任何警告,而在 Ubuntu 中却看到了?
I have recently made a cp clone (for University) and I happened to discover something I had never got the chance to.
This applies at least to GCC compiling a C source.
I did the main development of this specific C program in a Mac OS X (10.6.4), builds with Apple's /usr/bin/gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Copyright (C) 2007 Free Software Foundation, Inc.
However, I ran the tests in an Arch Linux virtual machine within the Mac, with the latest gcc (no additions, no customizations, no mods like Apple's)
gcc (GCC) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
And we had to build it in the class in the Ubuntu 10.04.1 LTS that we have there.
My Makefile was something like:
CC=gcc
#CFLAGS=-O0 -g -Wall
CFLAGS=-O3 -Wall -finline-functions
EXE=copy
compile:
$(CC) $(CFLAGS) -o $(EXE) main.c
So, I was always running (in every OS) gcc with -Wall
enabled.
Mac and Arch never showed any warning.
Ubuntu printed two warnings, with and without -Wall
do_copy.c: In function 'do_copy_file2file':
do_copy.c:27: warning: ignoring return value of 'realpath', declared with attribute warn_unused_result
do_copy.c: In function 'do_copy_symlink2file':
do_copy.c:117: warning: ignoring return value of 'symlink', declared with attribute warn_unused_result
Ubuntu's GCC version is the default for the distribution:gcc (Ubuntu 4.4.3-ubuntu5) 4.4.3
Why does that happen?
Why don't I see any warnings in the other two OSs and in Ubuntu I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ubuntu 强制执行一些 CFLAGS,如此处所示
Ubuntu enforces some CFLAGS as you can see here