From 705892f53e3d1bea3046fed854974a310521d88c Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 3 Oct 2011 21:10:11 +0000 Subject: Verify C++ support with CodeSourcery git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4016 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/libxx/libxx_new.cxx | 14 +++++++++++--- nuttx/libxx/libxx_newa.cxx | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'nuttx/libxx') diff --git a/nuttx/libxx/libxx_new.cxx b/nuttx/libxx/libxx_new.cxx index 49caf74f38..8ec725ca8b 100755 --- a/nuttx/libxx/libxx_new.cxx +++ b/nuttx/libxx/libxx_new.cxx @@ -58,14 +58,22 @@ // Name: new // // NOTE: -// This should take a type of size_t, which for ARM GCC is unsigned long. -// but size_t may actually be a different different type, in sys/include.h, -// it is typed as uint32_t. Need to REVISIT this. +// This should take a type of size_t. But size_t has an unknown underlying +// type. In the nuttx sys/types.h header file, size_t is typed as uint32_t +// (which is determined by architecture-specific logic). But the C++ +// compiler may believe that size_t is of a different type resulting in +// compilation errors in the operator. Using the underlying integer type +// instead of size_t seems to resolve the compilation issues. Need to +// REVISIT this. // //*************************************************************************** //void *operator new(size_t nbytes) +#ifdef CONFIG_CXX_NEWLONG void *operator new(unsigned long nbytes) +#else +void *operator new(unsigned int nbytes) +#endif { // We have to allocate something diff --git a/nuttx/libxx/libxx_newa.cxx b/nuttx/libxx/libxx_newa.cxx index e8c214d4d1..855160c412 100755 --- a/nuttx/libxx/libxx_newa.cxx +++ b/nuttx/libxx/libxx_newa.cxx @@ -58,18 +58,26 @@ // Name: new // // NOTE: -// This should take a type of size_t, which for ARM GCC is unsigned long. -// but size_t may actually be a different different type, in sys/include.h, -// it is typed as uint32_t. Need to REVISIT this. +// This should take a type of size_t. But size_t has an unknown underlying +// type. In the nuttx sys/types.h header file, size_t is typed as uint32_t +// (which is determined by architecture-specific logic). But the C++ +// compiler may believe that size_t is of a different type resulting in +// compilation errors in the operator. Using the underlying integer type +// instead of size_t seems to resolve the compilation issues. Need to +// REVISIT this. // //*************************************************************************** //void *operator new[](size_t size) +#ifdef CONFIG_CXX_NEWLONG void *operator new[](unsigned long nbytes) +#else +void *operator new[](unsigned int nbytes) +#endif { // We have to allocate something - if (nbytes< 1) + if (nbytes < 1) { nbytes = 1; } -- cgit v1.2.3