# Microcontroller support strings or other libraries [closed]

I heard some microcontrollers have a poor (or no) support for <string>s as a data type of C/C++ when programming. How to know if a microcontroller supports strings or other C/C++ libraries?

## closed as too broad by Chris Stratton, Michel Keijzers, Voltage Spike, Lior Bilia, Mitu RajMay 2 '18 at 5:33

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Can you provide where you got that information ? It's weird when you say so. – Long Pham Apr 30 '18 at 9:23
• To be very clear: 'string' is not a hardware concept, it's a programming one. Who needs to "support <string>" is the compiler used. The micro will only see it and manipulate it as a data array, like any other. – Vicente Cunha Apr 30 '18 at 9:23
• I have yet to find a micro controller compiler which does not support strings or does not have the strcpy strcmp etc. functions. After all they are a lot easier to implement than floats. – Oldfart Apr 30 '18 at 9:38
• @LongPham, stackoverflow.com/a/10745873/4685379. For example in order to include, say, a float into a string, you could use the sprintf() function. For this, you need a couple of functions available in <stdlib.h> and you can't embed stdlib for a tiny microcontroller. So my question is how to know if I can embed a library for a certain microcontroller. – Dima Dz Apr 30 '18 at 9:48
• This is now a very different question. in order to handle floating point numbers the compiler will link in some of the floating point library. You need to know how much space that extra code takes up, and whether it will fit inside your micro. The only way to be sure is to compile your code with the floating point handling and check if it will fit. – Steve G Apr 30 '18 at 9:53

Any micro will support small arrays of characters. They won't all support the full facilities that std::string or C's printf provide.

So if you need to convert float to string, there's nothing to stop you rolling your own tools to do the job, e.g. to treat a float as two integers separated by a decimal point, and to convert those integers to strings, etc. It's fairly simple basic programming as long as you don't need to handle scientific notation etc.

I shaved about 20k off the size of an executable by doing this (only handling numbers in a restricted range like +/-99999.9999) and eliminating printf.

• it would be useful, I guess, to know what was the total memory for your project before optimization? – Dima Dz Apr 30 '18 at 14:38
• Well at one stage that saving was over half the code. – Brian Drummond Apr 30 '18 at 19:52

If the software capable of handling std::string fits in memory, then your micro controller supports string.
If not, then it does not.

The question is not, "does the microcontroller support X?".
The question is: "does the microcontroller have enough memory to support X?".