Codewarrior Coldfire and VLA (Variable Length Array)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Codewarrior Coldfire and VLA (Variable Length Array)

661 Views
digit
Contributor I

I am porting code that use VLA (variable length array).  VLA is an array whose length is determined at run time (instead of at compile time).  VLA are part of C99.  It is similar to malloc & free but it is handled by compiler.

 

So I have checked C99 under settings -> Language settings.  That solve compile time error.

 

Now I'm stuck with linker error:

 

Link Error : Undefined : "__vla_alloc"

Link Error : Undefined : "__vla_free"

 

Do I miss an include ? Do I need to add a library ? Do I need to implement __vla_alloc and __vla_free myself ?

 

Need help

 

BTW I'm using Codewarrior 7.1 on MCF52235

Labels (1)
0 Kudos
3 Replies

414 Views
CrasyCat
Specialist III

Hello

 

     Did you link against the c99 run time library file?

     You need to link a library which includes implementation of these functions to your application.

 

CrasyCat

0 Kudos

414 Views
digit
Contributor I

My current project did not link any runtime lib as it handle everything down to reset vector.

 

What lib should I link to enable VLA on stack ?

 

 

0 Kudos

414 Views
CrasyCat
Specialist III

Hello

 

You need to link a library because the runtime function used for vla are implemented there.

The library to use depends on the application.

 

Please look at {Install}\MCU\Help\PDF\MCU_ColdFire_Compiler.pdf chapter Coldfire Runtime Libraries, section EWL for C and C++ Development. This should explain which library to use depending on your project configuration.

 

Note

As I do not know which version of CodeWarrior you are currently using I assumed you are using CodeWarrior for MCU V10.x.

If you are using another version, the name of the manual might be different.

 

 

CrasyCat

0 Kudos