Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
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? – Paul Jul 9 '15 at 11:29
    
The Arduino doesn't have an operating system, so therefore doesn't have a C standard library. – Zeb McCorkle Jul 9 '15 at 17:07
    
@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 Jul 10 '15 at 7:57
    
@EdgarBonet: TIL! – Zeb McCorkle Jul 10 '15 at 13:36

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

share|improve this answer
    
Thanks alot Sir! Ill keep that in mind – Zaid Tahir Jul 16 '15 at 8:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.