public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Strange GCC behavior
@ 2011-09-29 17:27 Nilesh Govindarajan
  2011-09-29 17:40 ` Michael Mol
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Nilesh Govindarajan @ 2011-09-29 17:27 UTC (permalink / raw
  To: Gentoo User Mailing List

Default function arguments in C are specified like this:

int func(int a = 10) {} // just a dummy function

Now I save that in a file called foo.c

The above piece of code is valid in C as well as C++

Now see this:

nilesh@Linux ~ $ cat /tmp/foo.c
int func(int a = 1) {}
nilesh@Linux ~ $ gcc /tmp/foo.c
/tmp/foo.c:1:16: error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token
nilesh@Linux ~ $ g++ /tmp/foo.c
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
nilesh@Linux ~ $ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/media/500GB/gentoo_portage/tmp/portage/sys-devel/gcc-4.5.3-r1/work/gcc-4.5.3/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --disable-lto
--enable-nls --without-included-gettext --with-system-zlib
--disable-werror --enable-secureplt --enable-multilib
--enable-libmudflap --disable-libssp --enable-libgomp --enable-cld
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/python
--enable-checking=release --disable-libgcj
--enable-languages=c,c++,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.3-r1
p1.0, pie-0.4.5'
Thread model: posix
gcc version 4.5.3 (Gentoo 4.5.3-r1 p1.0, pie-0.4.5)
nilesh@Linux ~ $ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/media/500GB/gentoo_portage/tmp/portage/sys-devel/gcc-4.5.3-r1/work/gcc-4.5.3/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --disable-lto
--enable-nls --without-included-gettext --with-system-zlib
--disable-werror --enable-secureplt --enable-multilib
--enable-libmudflap --disable-libssp --enable-libgomp --enable-cld
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/python
--enable-checking=release --disable-libgcj
--enable-languages=c,c++,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.3-r1
p1.0, pie-0.4.5'
Thread model: posix
gcc version 4.5.3 (Gentoo 4.5.3-r1 p1.0, pie-0.4.5)

Why is this happening? O_o

-- 
Nilesh Govindarajan
http://nileshgr.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-09-29 18:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 17:27 [gentoo-user] Strange GCC behavior Nilesh Govindarajan
2011-09-29 17:40 ` Michael Mol
2011-09-29 17:47   ` Nilesh Govindarajan
2011-09-29 17:43 ` Todd Goodman
2011-09-29 17:50   ` Michael Mol
2011-09-29 17:54   ` Nilesh Govindarajan
2011-09-29 18:00 ` David W Noon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox