469,601 Members | 2,039 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

Why in some compilers if a function is not declared, the compilergives out a "warning" and not an "error"??

In ARMCC, and Microsoft C, when i use a function which is never
defined or delared, it gives out a warning, not a compiling error?
why?

(This leads to a bug to my program since I seldom pay much attention
to warnings...)

Thanks for explanation!
Dec 9 '07 #1
4 1624
In article <0b**********************************@s12g2000prg. googlegroups.com>,
lostlander <lo************@gmail.comwrote:
>In ARMCC, and Microsoft C, when i use a function which is never
defined or delared, it gives out a warning, not a compiling error?
why?
It might not matter, if it never gets called (which may of course
depend on the input). I suppose it's a convenience to programmers
building a system incrementally.
>(This leads to a bug to my program since I seldom pay much attention
to warnings...)
The flaw here doesn't seem to be in the compiler!

-- Richard
--
:wq
Dec 9 '07 #2
lostlander wrote:
In ARMCC, and Microsoft C, when i use a function which is never
defined or delared, it gives out a warning, not a compiling error?
why?
Under "C90" rules, and under "K&R" rules even before them,
using an undeclared function is/was legal. The compiler assumes
that the unknown function takes an unknown number of arguments of
unknown types and returns an int value. If you write `f(42)' with
no declaration of `f', the compiler acts as it would if you had
previously written `int f();' as a declaration.

Under "C99" rules it is an error to use an undeclared function.
However, the Standard doesn't really distinguish between "errors"
and "warnings" (except in the case of the #error directive), so
the only real change is from "diagnostic optional" to "diagnostic
required."
(This leads to a bug to my program since I seldom pay much attention
to warnings...)
Trying for a Darwin Award, are you?

--
Eric Sosman
es*****@ieee-dot-org.invalid
Dec 9 '07 #3
On Sun, 9 Dec 2007 03:05:57 -0800 (PST), lostlander
<lo************@gmail.comwrote in comp.lang.c:
In ARMCC, and Microsoft C, when i use a function which is never
defined or delared, it gives out a warning, not a compiling error?
why?

(This leads to a bug to my program since I seldom pay much attention
to warnings...)
Please tell us your company's name so we can make a point of never
buying anything they make.

It you had worked for me, you wouldn't anymore.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Dec 9 '07 #4
lostlander wrote:
In ARMCC, and Microsoft C, when i use a function which is never
defined or delared, it gives out a warning, not a compiling error?
why?

(This leads to a bug to my program since I seldom pay much attention
to warnings...)
C90 permits calls to undeclared functions. The linking process,
however, usually generates an error if there are undefined references.
Some linkers have an option to generate an executable file even through
there are undefined references (called function doesn't exist). Are you
getting an undefined reference error from your linker (translation phase 8)?

--
Thad
Dec 9 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Chul Min Kim | last post: by
1 post views Thread by Andreas Poller | last post: by
1 post views Thread by ken.carlino | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.