Skip site navigation (1)Skip section navigation (2)
Date:      29 Nov 2005 08:33:25 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        Mamta BANSAL <mamta.bansal@st.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: questions about gcc options
Message-ID:  <441x0zlgt6.fsf@be-well.ilk.org>
In-Reply-To: <438AAD0F.90205@st.com>
References:  <438AAD0F.90205@st.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Mamta BANSAL <mamta.bansal@st.com> writes:

> Hello
>          for a c code i am using gcc compiler.
> i have doubt using -c option.
> for a c code the code compiles (without error ) with -c option even if
> i don't provide prior declaration of function.
> i mean i have try.c
> //*******************
> 
> void my_func( ){
> call_to_undeclared_func( );
> }
> //********************
> i do : gcc -c try.c , it works.
> is it the correct behaviour , i mean should it not ask for atleast
> declearation of call_to_undeclared_func( );
> 
> like if my make the same as try.cpp then usen use the same command it
> gives the foll. error.:
> 
> try.cpp: In function `void my_func()':
> try.cpp:2: implicit declaration of function `int
> call_to_undeclared_func(...)'
> which i feel is expected behaviour.

That doesn't require a diagnostic in C, but it does in C++.

If you want the diagnostics anyway, use the
-Wimplicit-function-declaration flag to the compiler.  Or -Wall, which
adds a pretty extensive set of non-required warnings.  See the gcc
manual if you want more information.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?441x0zlgt6.fsf>