Yahoo Groups archive

AVR-Chat

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

Message

GCC Maths problem

2006-01-30 by Richard Reeves

Hi folks,
I've just put WinAVR on my machine (I'm not much of a C programmer) 
and tried some simple code.  Then I tried some more simple code, as 
shown here:
//***************************
#include <avr/io.h>
#include <avr/delay.h>
#include <math.h>

int main(void)
{
double trig;
DDRA=0xff;
DDRB=0xff;

	while(1)
		{
		PORTA=~PORTA;
		trig=2*M_PI;
                //trig=sin(M_PI);
		PORTB=trig;
		_delay_ms(1);
		}
return(0);
}
//***************************
That works fine.  When I simulate it in Studio, I get $06 on PortB, 
proving that M_PI is found in math.h (and if I don't include math.h, 
it gives an expected error.)
However, if I un-comment the trig=sin(M_PI) line, I get the 
error "../gcc_test.c:21: undefined reference to `sin'"

I appreciate that I'm sending a double to a port, and that might not 
be a good idea, but why is the error saying what it is?

Thanks,




Richard

Attachments

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.