title: Arduino compiler and STL: Using std::vector and std::map
body: <p>While many posts say the STL libs are not generally available for arduino/embedded systems they seem to be installed on my Arduino compiler!  And many work.</p>
  
  <p><strong>Problem:</strong>  (complete sketch shown)</p>
  
  <pre><code>std::vector&lt;int&gt; foo;         // this works fine
  std::map&lt;int,int&gt; bar;    // adding this gives an error
  
  void setup() {}
  void loop() {}
  
  
  sketch_jun05a:4:1: error: 'map' in namespace 'std' does not name a type
   std::map&lt;int,int&gt; bar;
   ^
  </code></pre>
  
  <p><strong>So I don't know why std::vector would work but std::map would not work.</strong></p>
  
  <p>compiler platform:  Ardunio.app 1.8.12 on Mac OSX Catalina 
  Targeting:  ESP8266</p>
  
  <p><em>Detailed error message is pasted below.</em></p>
  
  <p><strong>Analysis:</strong><br>
  I went searching for map.h inside my arduino application  and I found what looks to be an extensive set STL library classes including stl_map.h </p>
  
  <p>these are located on my system at this path:</p>
  
  <pre><code>~/Library/Arduino15/packages//esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/xtensa-lx106-elf/include/c++/4.8.2
  
  and most of the interesting looking headers are in a subdir called "bits".
  </code></pre>
  
  <p>The other strange thing is that std::vector works without including any header files.  That's unexpected to me.</p>
  
  <p>I have not configured my search paths or set any environment variables so whatever the Arduino App does as installed is what path it is searching on.</p>
  
  <p><strong>I also can't find any documentation on this.</strong><br>
  Everything I do find says there isn't an STL for Arduino/ESP8266!  I did find some gitbub project libraries named ArduinoSTL and avr_stl which previously I did install as local user libraries (not in the system libs)  but I am not importing these in the sketch above.</p>
  
  <p>Here is the full error message:</p>
  
  <pre><code>/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/cems/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/cems/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/cems/Documents/Arduino/libraries -fqbn=esp8266:esp8266:d1:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=3000000 -vid-pid=1A86_7523 -ide-version=10812 -build-path /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707 -warnings=none -build-cache /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_cache_761223 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506 -prefs=runtime.tools.xtensa-lx106-elf-gcc-2.5.0-4-b40a506.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506 -prefs=runtime.tools.mkspiffs.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mkspiffs/2.5.0-4-b40a506 -prefs=runtime.tools.mkspiffs-2.5.0-4-b40a506.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mkspiffs/2.5.0-4-b40a506 -prefs=runtime.tools.python3.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.mklittlefs.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mklittlefs/2.5.0-4-fe5bb56 -prefs=runtime.tools.mklittlefs-2.5.0-4-fe5bb56.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mklittlefs/2.5.0-4-fe5bb56 -verbose /Users/cems/Documents/Arduino/sketch_jun05a/sketch_jun05a.ino
  /Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/cems/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/cems/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/cems/Documents/Arduino/libraries -fqbn=esp8266:esp8266:d1:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=3000000 -vid-pid=1A86_7523 -ide-version=10812 -build-path /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707 -warnings=none -build-cache /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_cache_761223 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506 -prefs=runtime.tools.xtensa-lx106-elf-gcc-2.5.0-4-b40a506.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506 -prefs=runtime.tools.mkspiffs.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mkspiffs/2.5.0-4-b40a506 -prefs=runtime.tools.mkspiffs-2.5.0-4-b40a506.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mkspiffs/2.5.0-4-b40a506 -prefs=runtime.tools.python3.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.mklittlefs.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mklittlefs/2.5.0-4-fe5bb56 -prefs=runtime.tools.mklittlefs-2.5.0-4-fe5bb56.path=/Users/cems/Library/Arduino15/packages/esp8266/tools/mklittlefs/2.5.0-4-fe5bb56 -verbose /Users/cems/Documents/Arduino/sketch_jun05a/sketch_jun05a.ino
  Using board 'd1' from platform in folder: /Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1
  Using core 'esp8266' from platform in folder: /Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1
  Detecting libraries used...
  /Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/include -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/lwip2/include -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10812 -DARDUINO_ESP8266_WEMOS_D1R1 -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1R1\"" -DFLASHMODE_DIO -DESP8266 -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266 -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/variants/d1 /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/sketch/sketch_jun05a.ino.cpp -o /dev/null
  Generating function prototypes...
  /Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/include -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/lwip2/include -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10812 -DARDUINO_ESP8266_WEMOS_D1R1 -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1R1\"" -DFLASHMODE_DIO -DESP8266 -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266 -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/variants/d1 /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/sketch/sketch_jun05a.ino.cpp -o /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/preproc/ctags_target_for_gcc_minus_e.cpp
  /Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/preproc/ctags_target_for_gcc_minus_e.cpp
  Compiling sketch...
  /Users/cems/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1/python3 /Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/signing.py --mode header --publickey /Users/cems/Documents/Arduino/sketch_jun05a/public.key --out /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/core/Updater_Signing.h
  /Users/cems/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/include -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/lwip2/include -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/sdk/libc/xtensa-lx106-elf/include -I/var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10812 -DARDUINO_ESP8266_WEMOS_D1R1 -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1R1\"" -DFLASHMODE_DIO -DESP8266 -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266 -I/Users/cems/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/variants/d1 /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/sketch/sketch_jun05a.ino.cpp -o /var/folders/py/rycjfnrd0t13_pm4d11yyd2m0000gn/T/arduino_build_263707/sketch/sketch_jun05a.ino.cpp.o
  sketch_jun05a:4:1: error: 'stl_map' in namespace 'std' does not name a type
   std::stl_map&lt;int,int&gt; bar;
   ^
  exit status 1
  'stl_map' in namespace 'std' does not name a type
  </code></pre>