CodeWarrior and C++ Standard Library

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

CodeWarrior and C++ Standard Library

1,910 Views
spietari
Contributor I

Hi,

 

I've just would like to have a definitive answer to whether I can use Standard  C++ Library classes such as std::string and std::vector. I've got some old classes that I'd need to reuse that rely on those...

 

Is it a question of CW version perhaps too? I'm targeting HCS12.

 

Thanks,

Seppo

Labels (1)
Tags (1)
0 Kudos
3 Replies

598 Views
Lundin
Senior Contributor IV
I cannot give you a definite answer, but I know that CW claims to conform to something called "ANSI draft", which is completely irrelevant standard-wise. A standard compiler would claim conformance to the only relevant C++ standard ISO/IEC 14882:1998 or later. I know that there are plenty of standard C++ features lacking even when you select the "full C++" option, for example things as mundane as the bool type and exception handling.

On the other hand, we are talking about a tight, very code-efficient microcontroller for realtime applications. In such applications it doesn't make sense to use STL. Templates and dynamic memory allocation will slaughter all resources on the processor. And for security reasons they will also be banned in all industrial/automotive applications, and in most telecom apps too. For consumer electronics and hobbyist projects it could perhaps make sense to use STL.
0 Kudos

598 Views
dmctek
Contributor I

As per previous comments, I really can't see anything like STL being supported on this device in fact I'm almost sure that the C environment would also be cut down for example some implementations of printf in the C runtime library can run anywhere between 6-8kb.

 

 

Cheers,

 

Dave,

Scotland.

 

Embedded OS Design Consultant for public/private telecoms switch projects

dmctek.googlepages.com/dload.html

0 Kudos

598 Views
Lundin
Senior Contributor IV
Actually, CW fully supports ISO C 9899:1990. This is one of the strengths with this compiler. They have support for stdio and other such libs you don't need in a mcu. Through clever implementations of #pragma, you can write code for interrupts, memory allocation etc and still be ISO C compliant. The only time you must use non-standard C is during inline asm.
0 Kudos