questions about gcc options

Lowell Gilbert freebsd-questions-local at be-well.ilk.org
Tue Nov 29 13:33:29 GMT 2005


Mamta BANSAL <mamta.bansal at 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.


More information about the freebsd-questions mailing list