user14761: I have a project that I need to use a vector, I have tried to get several libraries to compile with out luck. The one that has gotten the closest is  Andy Brown's AVR-STL. I keep getting the error:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: redefinition of 'void* operator new(size_t, void*)'

I am sure that this is a simple fix, I just have no idea how. If this library is no longer viable then can someone else recommend another one?
Here is the code I am trying to compile
#include "Arduino.h"
#include "iterator"
#include "vector"
#include "pnew.cpp"

std::vector<int> test;

void setup(void) {

    Serial.begin(57600);
}

void loop(void) {

    test.push_back(1);
    Serial.println("Pushed");
}

And the full output:
14:57:27 **** Incremental Build of configuration Release for project MegaTesting ****
"C:\\Eclipse\\eclipse\\arduinoPlugin\\tools\\make\\make" all 
'Building file: ../.ino.cpp'
'Starting C++ compile'
"C:\Eclipse\eclipse\arduinoPlugin\tools\arduino\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR     -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\cores\arduino" -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\variants\mega" -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL" -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL\utility" -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.o" -D__IN_ECLIPSE__=1 -x c++ "../.ino.cpp"  -o  ".ino.cpp.o"   -Wall
cc1plus.exe: warning: C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL\utility: not a directory [enabled by default]
In file included from C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/stl_iterator_base.h:38:0,
                 from C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/iterator:40,
                 from ../.ino.cpp:8:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h: In static member function 'static void _TrivialIterator_concept_specification<_TrivialIterator>::_TrivialIterator_requirement_violation(_TrivialIterator)':
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h:572:16: warning: typedef '__T' locally defined but not used [-Wunused-local-typedefs]
     value_type __T;
                ^
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h: In static member function 'static void _Allocator_concept_specification<_Alloc>::_Allocator_requirement_violation(_Alloc)':
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h:799:39: warning: typedef '_Tp' locally defined but not used [-Wunused-local-typedefs]
   typedef typename _Alloc::value_type _Tp;
                                       ^
In file included from ../MegaTesting.ino:3:0,
                 from ../.ino.cpp:14:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp: In function 'void* operator new(size_t, void*)':
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: redefinition of 'void* operator new(size_t, void*)'
 void* operator new(size_t size_,void *ptr_){
       ^
In file included from ../.ino.cpp:10:0:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: 'void* operator new(size_t, void*)' previously defined here
 void* operator new(size_t size_,void *ptr_){
       ^
subdir.mk:24: recipe for target '.ino.cpp.o' failed
make: *** [.ino.cpp.o] Error 1

14:57:28 Build Finished (took 600ms)


user16458: It looks like new is redefined. I see that you include cpp file, that contains implementation - this is rather unfortunate design, but that's how it is done. 
Anyway, it seems that this file is already being compiled elsewhere. Have you tried to remove this include? What happens if you remove it?
Apart from that problem, you must be aware that dynamic memory management in such small system yelds risk of memory fragmentation that eventually leads to failed allocations.

14761: <p>I have a project that I need to use a vector, I have tried to get several libraries to compile with out luck. The one that has gotten the closest is  <a href="http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/" rel="nofollow">Andy Brown's AVR-STL</a>. I keep getting the error:</p>

<pre><code>C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: redefinition of 'void* operator new(size_t, void*)'
</code></pre>

<p>I am sure that this is a simple fix, I just have no idea how. If this library is no longer viable then can someone else recommend another one?</p>

<p>Here is the code I am trying to compile</p>

<pre><code>#include "Arduino.h"
#include "iterator"
#include "vector"
#include "pnew.cpp"

std::vector&lt;int&gt; test;

void setup(void) {

    Serial.begin(57600);
}

void loop(void) {

    test.push_back(1);
    Serial.println("Pushed");
}
</code></pre>

<p>And the full output:</p>

<pre><code>14:57:27 **** Incremental Build of configuration Release for project MegaTesting ****
"C:\\Eclipse\\eclipse\\arduinoPlugin\\tools\\make\\make" all 
'Building file: ../.ino.cpp'
'Starting C++ compile'
"C:\Eclipse\eclipse\arduinoPlugin\tools\arduino\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR     -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\cores\arduino" -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\variants\mega" -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL" -I"C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL\utility" -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.o" -D__IN_ECLIPSE__=1 -x c++ "../.ino.cpp"  -o  ".ino.cpp.o"   -Wall
cc1plus.exe: warning: C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL\utility: not a directory [enabled by default]
In file included from C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/stl_iterator_base.h:38:0,
                 from C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/iterator:40,
                 from ../.ino.cpp:8:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h: In static member function 'static void _TrivialIterator_concept_specification&lt;_TrivialIterator&gt;::_TrivialIterator_requirement_violation(_TrivialIterator)':
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h:572:16: warning: typedef '__T' locally defined but not used [-Wunused-local-typedefs]
     value_type __T;
                ^
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h: In static member function 'static void _Allocator_concept_specification&lt;_Alloc&gt;::_Allocator_requirement_violation(_Alloc)':
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h:799:39: warning: typedef '_Tp' locally defined but not used [-Wunused-local-typedefs]
   typedef typename _Alloc::value_type _Tp;
                                       ^
In file included from ../MegaTesting.ino:3:0,
                 from ../.ino.cpp:14:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp: In function 'void* operator new(size_t, void*)':
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: redefinition of 'void* operator new(size_t, void*)'
 void* operator new(size_t size_,void *ptr_){
       ^
In file included from ../.ino.cpp:10:0:
C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: 'void* operator new(size_t, void*)' previously defined here
 void* operator new(size_t size_,void *ptr_){
       ^
subdir.mk:24: recipe for target '.ino.cpp.o' failed
make: *** [.ino.cpp.o] Error 1

14:57:28 Build Finished (took 600ms)
</code></pre>
 16458: <p>It looks like <code>new</code> is redefined. I see that you include <code>cpp</code> file, that contains <em>implementation</em> - this is rather unfortunate design, but that's how it is done. </p>

<p>Anyway, it seems that this file is already being compiled elsewhere. Have you tried to remove this include? What happens if you remove it?</p>

<p>Apart from that problem, you must be aware that dynamic memory management in such small system yelds risk of memory fragmentation that eventually leads to failed allocations.</p>
