[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Undefined reference - Why?
From: |
Klaus Rotter |
Subject: |
Re: [avr-gcc-list] Undefined reference - Why? |
Date: |
Sun, 4 Mar 2001 16:55:49 +0100 |
User-agent: |
Mutt/1.2.5i |
On Sun, Mar 04, 2001 at 04:05:27PM +0100, Bernt Hustad Hembre wrote:
> #include <math.h>
> void a_function(int tall);
> int main(void){
> int hoyde;
> double trykk;
>
> hoyde = pow(2,2);
> a_function(hoyde);
> // trykk = hoyde * 1.234;
> return 0;
> } /* main */
>
> void a_function(int tall){
> }
> M:\prosjekt\tuger\hw\firmware/tuger.c:10: undefined reference to `pow'
> But if I change this:
> a_function(hoyde);
> // trykk = hoyde * 1.234;
> to this:
> // a_function(hoyde);
> trykk = hoyde * 1.234;
> It compiles without any errormessages...
What do you expect ? You are compiling with -O3. If you comment out
a_function(hoyde) the optimzer recognices that hoyde and trykk are
calculated but _never_ used. So they will be optimized out. Compile this
withou any optimization and you get what you expected. You can also try
"return hoyde" instead of "return 0".
--
Klaus Rotter * mailto:address@hidden