Linux下Gcc编译没提示,没生成文件?

       最近学习Linux C,一直都是看书,今天终于实践了下,果然发现问题了。我用gcc编译文件,不报错也没有任何提示,按照我的经验觉得应没有任何问题了,其中还用gcc -v 看了下,也没发现任何有价值的信息。不过,也了解了下-v 参数的用法。
      系统环境:BackTrack 5 r3 GNOME  gcc
      安装书上的代码定义了一个max函数,写法是int max =(int i,int y) ,我记得还有一个写法,可以定义为int max=(int i,y),我怕出错就按书上的写法编译的,生成了a.out。没问题,我就测试我的那个想法,int max=(int i,j),然后,修改源码后编译,报错了。
root@bt:/home/c/5# gcc b.c
b.c:3: error: expected declaration specifiers or ‘...’ before ‘j’
b.c: In function ‘max’:
b.c:5: error: ‘j’ undeclared (first use in this function)
b.c:5: error: (Each undeclared identifier is reported only once
b.c:5: error: for each function it appears in.)
b.c: In function ‘main’:
b.c:21: error: too many arguments to function ‘max’
      然后,我又修改回了max = (int i, int y),但是,我定义的时候修改了下int的赋值,并保存为b.c,然后编译,这个时候出问题了。。
root@bt:/home/c/5# gcc b.c
root@bt:/home/c/5# ls
a.c  a.out  b.c
root@bt:/home/c/5# gcc b.c
root@bt:/home/c/5# vi b.c
root@bt:/home/c/5# gcc b.c
root@bt:/home/c/5# ls
a.c  a.out  b.c
     b.out呢?我生成了几次,还是一样的,我就开始用 gcc -v 参数跟踪,但是还是没有发现问题。
root@bt:/home/c/5# gcc -v b.c
Using built-in specs.    //使用内建specs
Target: x86_64-linux-gnu //目标
//配置为
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5.1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix  //线程模型
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)  //gcc版本
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/cc1 -quiet -v b.c -D_FORTIFY_SOURCE=2 -quiet -dumpbase b.c -mtune=generic -auxbase b -version -fstack-protector -o /tmp/ccx4GzQz.s
GNU C (Ubuntu 4.4.3-4ubuntu5.1) version 4.4.3 (x86_64-linux-gnu)
  compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed
/usr/include
End of search list.
GNU C (Ubuntu 4.4.3-4ubuntu5.1) version 4.4.3 (x86_64-linux-gnu)
  compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 462394bb0ac77cba16b6fb6b32589358
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
as -V -Qy -o /tmp/ccfLDsda.o /tmp/ccx4GzQz.s
GNU assembler version 2.20.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.20.1-system.20100303
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/collect2 --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../.. /tmp/ccfLDsda.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crtn.o
       最后多次测试发现:如果你只用gcc +文件名,而不带其它参数,那么生成的文件总是a.out。

本文由站长原创或收集,不代表本站立场,如若转载,请注明出处:http://www.yesck.com/post/521/

本文 暂无 评论

回复给

欢迎点评

联系我们

站长QQ:8117829

站长邮件:8117829@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code