Skip to content

Commit

Permalink
Guard new and delete operators to prevent “multiple definition” compi…
Browse files Browse the repository at this point in the history
…lation errors
  • Loading branch information
amotl committed Jan 10, 2017
1 parent f58e668 commit 80d70de
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/del_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

// Arduino 1.0 contains an implementation for this.
#if ARDUINO < 100

#include <new>
#include <cstdlib>
#include <func_exception>

_UCXXEXPORT void operator delete(void* ptr) throw(){
free(ptr);
}

#endif
5 changes: 5 additions & 0 deletions src/del_opv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

// Arduino 1.0 contains an implementation for this.
#if ARDUINO < 100

#include <new>
#include <cstdlib>
#include <func_exception>

_UCXXEXPORT void operator delete[](void * ptr) throw(){
free(ptr);
}

#endif
5 changes: 5 additions & 0 deletions src/new_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

// Arduino 1.0 contains an implementation for this.
#if ARDUINO < 100

#include <new>
#include <cstdlib>
#include <func_exception>
Expand All @@ -33,3 +36,5 @@ _UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc){
}
return p;
}

#endif
5 changes: 5 additions & 0 deletions src/new_opv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

// Arduino 1.0 contains an implementation for this.
#if ARDUINO < 100

#include <new>
#include <cstdlib>
#include <func_exception>
Expand All @@ -33,3 +36,5 @@ _UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc){
}
return p;
}

#endif

0 comments on commit 80d70de

Please sign in to comment.