Codewarrior Coldfire and VLA (Variable Length Array)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Codewarrior Coldfire and VLA (Variable Length Array)

1,398 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,151 次查看
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 项奖励
回复

1,151 次查看
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 项奖励
回复

1,151 次查看
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 项奖励
回复