atof

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

atof

2,290件の閲覧回数
Emoretti
Contributor I

Hi, i write this simple code for mcf51jm128 and the compiler send this error

 

please help

 

 

 

" Link Error   : Undefined : "atof" Referenced from "main" in main.c "

and

Link Error   : Undefined : "atoi"  Referenced from "main" in main.c "

 

 

#include <stdlib.h>
static char s[] = "-49.3";

static char t[]= "125";

float f;

int i;

void main(void) {

  f = atof(s);
  i = atoi(t);
 

ラベル(1)
タグ(1)
0 件の賞賛
4 返答(返信)

539件の閲覧回数
jky
Contributor I

Hello,

 

I have Codewarrior 6.2 and am compiling for a coldfire V1 chip.

 

I solved this problem:

 

1.  Libraries in project

            fp_coldfire_ieee_nodiv.a

            C_4i_CF_RegABI_Runtime.a

            C_4i_CF_RegABI_MATH_MSL.a

 

2. Open up  MSL_C.CF.v1.mcp project file.

    a.  Set target to MATH 4i ColdFire RegABI

    b.  Open ansi_prefix.CF.v1.h

            1. add   #define __CF_USE_FULL_LIBS__     1 

                   at the start of file 

 

            2. change #define _MSL_HIWARE_COMP  1 to 

                          #define _MSL_HIWARE_COMP   0

            3. change #define _MSL_C99    0  to 

                          #define _MSL_C99    1

 

    c. add ansi_fp.c to  to project it is in directory

            <wherever Codewarrior instaled>\Coldfire_Support\msl\MSL_C\MSL_Common_Embedded\Src

 

    d. build MATH 4i ColdFire RegABI target

 

If we did everything right it should build fine.  And a check mark will appear next to C_4i_CF_RegABI_MATH_MSL.a library in your application project.

 

Then viola atof will link.

 

When I did this my binary image grew about 6K

 

Oh before I did this I had already done the fix for %f format

working  FAQ 28628

 

Don't know if you have to this first to wore out to undo and

see if it matters..  But if you want to print floats you will have

to follow FAQ 28628 

 

Hope this helps

 

John

  

0 件の賞賛

539件の閲覧回数
Emoretti
Contributor I

helo

 

 i ´am create a new project with the wizard and load this libraries, I´am uninstal and instal codwarrior and send Link Error   : Undefined : "atof"

 

plese help

 

fp_coldfire_nodiv.a

C_4i_CF_RegABI_MATH_MSL.a

C_4i_CF_RegABI_Runtime.a

 

 

or read 

 

Help\PDF\ColdFireV1_Build_Tools_Reference.pdf, chapter 20, ColdFire Runtime Libraries.

 

Daniel

0 件の賞賛

539件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee

Hmm,

not sure why those methods are not defined.

atoi can easely be implemented based on strtol:

 

int atoi(const char * str){  return(strtol(str, NULL, 10));}

For atof all the source code is available, not sure why it is not built into the library.

 

You can add those files to your project to get a working atof implementation:

 

ColdFire_Support\msl\MSL_C\MSL_Common\Src\strtold.c

ColdFire_Support\msl\MSL_C\MSL_ColdFire\Src\math_cf.c

ColdFire_Support\msl\MSL_C\MSL_Common\Src\scanf.c

ColdFire_Support\msl\MSL_C\MSL_Common_Embedded\Src\ansi_fp.c

 

As alternative a simple special purpose atof might save a bit of flash space.

 

Daniel

 

0 件の賞賛

539件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee

This means that you do not link the corresponding library.

 

Create a new project with the wizard to see which libraries to use

 

or read 

 

Help\PDF\ColdFireV1_Build_Tools_Reference.pdf, chapter 20, ColdFire Runtime Libraries.

 

Daniel

0 件の賞賛