Re: Undefined functions in C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ian Wienand <ianw@xxxxxxxxxxxxxxxxxx> writes:

> > As you note, gcc in c99 mode will always give a warning for an
> > undeclared function; this is not true in c89 mode.  In c99 mode, the
> > compiler will give an error if you use the -pedantic-errors option.
> > Or the -Werror-implicit-function-declaration option.  Or the -Werror
> > option.
> 
> So do you know why if it is against the standard, gcc in with
> --std=c99 requires it be explicitly turned into an error?  Is it just
> a backwards/cross compatibility thing?

I haven't bothered to track down the patch which introduced this, but
I would speculate that 1) it will be desirable to eventually switch
gcc to default to c99 mode, but 2) it will not be desirable to break
lots of existing code at that time.  Given traditional C usage,
requiring a function declaration can be reasonably viewed as a
pedantic requirement, appropriate for -pedantic-errors.  In general,
if you want gcc to enforce strict adherence to the relevant standard,
you must use -pedantic-errors.

Of course there is a very reasonable coding style in which functions
should always be declared for use.  For that coding style, there is
-Werror-implicit-function-declaration.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux