Re: problems with math.h and -lm

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Ralf Hildebrandt-2
Dmitry wrote

> fixed...
> logf(), expf()

O.k., thanks - this works, but could you explain why did you use the names
logf() and expf() instead of the standard names log() and exp()? This is
pretty confusing, because if one is reading a ANSI C standard library
description while programming he expects the standard names and therefore
will trap into the pit, because log() and exp() result in an "undefined
reference" error.

Note: The same holds also for pow(), which has to be called using powf(). In
contrast sin() and cos() are defined and work.

Ralf


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Rolf Freitag

Hi,

> ... could you explain why did you use the names
> logf() and expf() instead of the standard names log() and exp()?

logf, expf, powlf etc. are ANSI C functions defined as functions with float argument(s).
The functions without the f are functions with double argument(s) and the functions
logl, expl, powl are functions with long double argument(s).
See chapter 7.12 in C99.

Regards,

Rolf



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Ralf Hildebrandt-2
[hidden email] wrote

> > ... could you explain why did you use the names
> > logf() and expf() instead of the standard names log() and exp()?
>
> logf, expf, powlf etc. are ANSI C functions defined as functions with
> float argument(s).
> The functions without the f are functions with double argument(s) and the
> functions
> logl, expl, powl are functions with long double argument(s).
> See chapter 7.12 in C99.

O.k., thanks for the explanation.
But this means, that the double funtions log(), exp() and pow() are missing.
Is this an error or does MSP430-GCC not support them? (sin() and cos() are
available, which should be also double functions. sinf() and cosf() do
exist, too.)

Ralf


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Rolf Freitag
In reply to this post by Ralf Hildebrandt-2

Hi,

on small microcontroller without hardware FP it usually does not make sense to
use double or long double. Most of the programs do not use any floating point operations,
because it needs much more code, RAM and CPU time.
That's also the reason why C99 features like complex numbers (with complex inf and NAN)
are usually not available for microcontroller.

Regards,

Rolf


[hidden email] schrieb am 24.06.05 11:49:25:

>
> [hidden email] wrote
>
> > > ... could you explain why did you use the names
> > > logf() and expf() instead of the standard names log() and exp()?
> >
> > logf, expf, powlf etc. are ANSI C functions defined as functions with
> > float argument(s).
> > The functions without the f are functions with double argument(s) and the
> > functions
> > logl, expl, powl are functions with long double argument(s).
> > See chapter 7.12 in C99.
>
> O.k., thanks for the explanation.
> But this means, that the double funtions log(), exp() and pow() are missing.
> Is this an error or does MSP430-GCC not support them? (sin() and cos() are
> available, which should be also double functions. sinf() and cosf() do
> exist, too.)
>
> Ralf
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Ralf Hildebrandt-2
[hidden email] wrote:

> on small microcontroller without hardware FP it usually does not make sense to
> use double or long double. Most of the programs do not use any floating point operations,
> because it needs much more code, RAM and CPU time.

I totally agree with you. It would be only for the sake of completeness - if really
someone need this.


Ralf


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Rolf Freitag
In reply to this post by Ralf Hildebrandt-2

Hi,

i built mspgcc from the CVS sources of yesterday but sinf, logf etc. still
do not work, even with #include <math.h>:

> msp430-gcc -mmcu=msp430x149 -lm -o test2.elf test2.c
/tmp/ccm6TMBK.o(.text+0xe0): In function `main':
: undefined reference to `expf'

That hello world program can be compiled, flashed and it works without
problems when i comment the line with expf. So it's only expf that does
not work.
So is it vaporware or is there a special trick?

Regards,

Rolf

[hidden email] schrieb am 03.06.05 18:41:14:

>
> fixed...
> logf(), expf()
>
> ~d
>
> On Friday 03 June 2005 07:54, Dmitry wrote:
> > > But why -lm has to be given at the end?
> >
> > that's how the one-pass linker works...
> >
> > > > looks like I forgot to add strait calls of these functions...
> > >
> > > O.k.. Do you add this bug to the bug tracker at sourceforge.net? (So I
> > > can monitor, if the bug has been fixed.)
> >
> > I'll fix it, say, tonight...
> >
> > cheers,
> > ~d
> >
> > > Ralf
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by Yahoo.
> > > Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> > > Search APIs Find out how you can build Yahoo! directly into your own
> > > Applications - visit
> > > http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> > > _______________________________________________
> > > Mspgcc-users mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/mspgcc-users
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by Yahoo.
> > Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> > Search APIs Find out how you can build Yahoo! directly into your own
> > Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> > _______________________________________________
> > Mspgcc-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: problems with math.h and -lm

Rolf Freitag
In reply to this post by Ralf Hildebrandt-2

Hi,

with an inspiration i found the secret trick: -lm has to be used as the last argument:

> msp430-gcc -mmcu=msp430x149 -O2 -Wall -g  -c -o test2.o test2.c
> msp430-gcc -mmcu=msp430x149 -o test2.elf test2.o -lm
> echo $?
0

This trick is not nessisary e. g. on PC or ARM or for crosscompiling for ARM.
The trick is so secret that in the code examples there is no
#include <math.h>
and the trick can't be found in the manual!

Regards,

Rolf


[hidden email] schrieb am 02.07.05 02:01:19:

>
>
> Hi,
>
> i built mspgcc from the CVS sources of yesterday but sinf, logf etc. still
> do not work, even with #include <math.h>:
>
> > msp430-gcc -mmcu=msp430x149 -lm -o test2.elf test2.c
> /tmp/ccm6TMBK.o(.text+0xe0): In function `main':
> : undefined reference to `expf'
>
> That hello world program can be compiled, flashed and it works without
> problems when i comment the line with expf. So it's only expf that does
> not work.
> So is it vaporware or is there a special trick?
>
> Regards,
>
> Rolf
>
> [hidden email] schrieb am 03.06.05 18:41:14:
> >
> > fixed...
> > logf(), expf()
> >
> > ~d
> >
> > On Friday 03 June 2005 07:54, Dmitry wrote:
> > > > But why -lm has to be given at the end?
> > >
> > > that's how the one-pass linker works...
> > >
> > > > > looks like I forgot to add strait calls of these functions...
> > > >
> > > > O.k.. Do you add this bug to the bug tracker at sourceforge.net? (So I
> > > > can monitor, if the bug has been fixed.)
> > >
> > > I'll fix it, say, tonight...
> > >
> > > cheers,
> > > ~d
> > >
> > > > Ralf



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users