I have a code in Visual studio that I want to implement in Arduino. But there is a problem. Many libraries usable in Visual Studio aren't usable in the Arduino IDE. How can I use them in my Arduino code? To be precise, the libraries I want to use are
#include <iostream>
#include <iomanip>
#include <queue>
#include <string>
#include <math.h>
#include <ctime>
I know I have <iostream>
available in Arduino. <math.h>
is also
available I think along with the <string>
library. The main problem is
to how to use #include<queue>
and its functions such as
priority_queue()
and other functions of iosteam like .pop()
? Any
help would be highly appreciated.
-
Weird, I can remember using the same ATMega328P with another compiler, where it did work. Though you can check if an external library fits your needs: playground.arduino.cc/Code/QueueList But I would understand if you prefer a solution rather than a work-around?aaa– aaa2015年07月09日 11:29:17 +00:00Commented Jul 9, 2015 at 11:29
-
The Arduino doesn't have an operating system, so therefore doesn't have a C standard library.Piper McCorkle– Piper McCorkle2015年07月09日 17:07:35 +00:00Commented Jul 9, 2015 at 17:07
-
1@mypal125: The Arduino does have a standard C library (avr-libc for the AVR based boards). What it lacks is the C++ STL, but see Nick Gammon's answer on how to add it.Edgar Bonet– Edgar Bonet2015年07月10日 07:57:11 +00:00Commented Jul 10, 2015 at 7:57
-
@EdgarBonet: TIL!Piper McCorkle– Piper McCorkle2015年07月10日 13:36:39 +00:00Commented Jul 10, 2015 at 13:36
1 Answer 1
Some of the libraries you mention (iomanip, iostream, queue, string) are part of the STL - Standard Template Library. Whilst it does not ship with the IDE download, you can install it yourself. See The Standard Template Library (STL) for AVR with C++ streams - a port to the Arduino by Andy Brown.
I have some implementation notes here.
Be aware that a lot of Arduinos don't have much RAM, so you need to use libraries like this with caution.
Library download: AVR standard template library, version 1.1.1 - 197.29 kB