Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Re: Unable to get GCC to treat "implicit function delaration" as an error

Re: Unable to get GCC to treat "implicit function delaration" as an error

2011-01-26 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Chuck Hackett" <egroupscdh@...> wrote:
> -Werror-implicit-function-declaration
As I read the documentation, this option is superfluous if -Wall is given.

To get warnings to be treated as errors (probably a good idea), use
-Werror.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

Unable to get GCC to treat "implicit function delaration" as an error

2011-01-26 by Chuck Hackett

I ended up chasing a bug because I had not noticed that one out of sixteen compiles
in a rebuild issued warnings about implicit function declarations which, of course,
caused an invalid calling sequence to be emitted.  

I thought I had set up the compiler options to treat this as an error but apparently
not.

I've re-read the gcc manual and searched the web but I can't figure out what I'm
doing wrong.

The following compiler command (WinAVR 20200110):

avr-gcc.exe -mmcu=atmega32 -Wall -fms-extensions
-Werror-implicit-function-declaration -DF_CPU=14745600UL  -g  -std=c99
-I..\BC002_MultiTaskCB -IC:\FreeRTOSV6.1.0\Source\include
-IC:\FreeRTOSV6.1.0\Source\portable\GCC\ATMega323 -ICommon_include
-IC:\WinAVR-20071221\avr\include  -c TrackIn.c -o obj\Debug\TrackIn.o

Produces the following output:

TrackIn.c: In function 'TrackIn__XmitStatus':
TrackIn.c:41: warning: implicit declaration of function 'CAN_XmitNM'
TrackIn.c: In function 'TrackIn__Init':
TrackIn.c:242: warning: implicit declaration of function 'CAN_XmitObjectStart'

And did not generate an error.

It was my understanding that the "-Werror-implicit-function-declaration" compiler
option would cause the warning to be turned into an error even in the presence of
the "-Wall" option.  I also tried "-Werror=implicit-function-declaration" with no
success.

Any idea what I'm doing wrong?

Re: Unable to get GCC to treat "implicit function delaration" as an error

2011-01-26 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Chuck Hackett" <egroupscdh@...> wrote:
> "Compiler optimizations disabled; functions from <util/delay.h>
> won't work as> designed"
Clearly, you can't use the delay.h macros/functions without optimization enabled so if you insist on having optimization off, simply comment out the inclusion of delay.h.

> [U]ntil I compile with optimization after everything is working.
I understand the intention, it is common among new avr-gcc users (see the many posts at AVR Freaks).  You'll find, however, that the generated code with optimization turned off is downright horrific.  My advice is to use -Os or a similar high level of optimization and deal with the very rare optimization issue as it arises.  I've been compiling our AVR code base with -Os for seven years or more and have never encountered bad code due to optimization.

The counter argument is that it makes debugging somewhat more difficult.  I claim that you quickly get accustomed to the types of things the optimizer does and you'll be able to debug your code with ease.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

RE: [AVR-Chat] Re: Unable to get GCC to treat "implicit function delaration" as an error

2011-01-26 by Chuck Hackett

> From: Don Kinzer
> ....
> As I read the documentation, this option is superfluous if -Wall is given.
> 
> To get warnings to be treated as errors (probably a good idea), use
> -Werror.

With -Werror several compiles fail because of:

"c:/winavr-20100110/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning
"Compiler optimizations disabled; functions from <util/delay.h> won't work as
designed"

Which I know but don't care until I compile with optimization after everything is
working.  I couldn't find a compiler directive to treat "#warning" as a warning in
the presence of "-Werror".

I tried removing "-Wall" leaving:

"-fms-extensions -Werror=implicit-function-declaration" and tried
"-fms-extensions -Werror-implicit-function-declaration"

but the implicit declarations were still not treated as an error.
 
Cheers,

Chuck Hackett
"Good judgment comes from experience, experience comes from bad judgment"
7.5" gauge Union Pacific Northern (4-8-4) 844 http://www.whitetrout.net/Chuck

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.