Compile problem - android-ndk-r6 - x86

185 views
Skip to first unread message

esio

unread,
Aug 2, 2011, 4:28:55 AM8/2/11
to android-ndk
Hey, I have a problem with compiling my project using the NDK. I
compile it using the standalone-toolchain for x86, and I have an issue
with the function:

void* operator new( size_t size );

error:
error: 'operator new' takes type 'size_t' ('unsigned int') as first
parameter

I wrote simple program to test this issue:

#include <stdio.h>
#include <iostream>
#include <new>
using namespace std;
typedef size_t SIZE_T;
class Hello
{
public:
Hello(){printf("hello");}
~Hello(){}
};

class Test {
public:
Test ();
virtual ~Test ();
void* operator new(size_t size);
private:
/* data */
};
int main() {
Hello* h = new Hello();
delete h;
return 0;
}

And i get same error...
Can anybody help me?

mhorn

unread,
Aug 2, 2011, 7:41:44 PM8/2/11
to android-ndk
Try adding "-DANDROID" to your compile line.

At least one of the system header files for x86 is expecting that
macro to be defined to properly set size_t.
When you use the "ndk-build" script it includes that macro on the
command line for you.

Hopefully this can be fixed in the pending NDK r6b release.

mhorn

unread,
Aug 3, 2011, 3:39:50 AM8/3/11
to android-ndk
Try adding "-DANDROID" to your compile command line.

When you use the "ndk-build" script, it defines this macro.

It appears that the header file which sets 'size_t' requires that
macro to be defined.

I'll follow up if the header files needs to be changed to use a
different macro which is already defined by the standalone toolchain
(__ANDROID__) or if the standalone toolchain should also define the
ANDROID macro automatically.



On Aug 2, 1:28 am, esio <zadeq...@gmail.com> wrote:

David Turner

unread,
Aug 3, 2011, 6:17:46 AM8/3/11
to andro...@googlegroups.com
On Wed, Aug 3, 2011 at 1:41 AM, mhorn <mark...@gmail.com> wrote:
Try adding "-DANDROID" to your compile line.

At least one of the system header files for x86 is expecting that
macro to be defined to properly set size_t.

that looks like a bug in the header file, it should only rely on __ANDROID__
Can you file a bug for this on b.android.com? thanks.
 
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


David Turner

unread,
Aug 3, 2011, 6:19:22 AM8/3/11
to andro...@googlegroups.com
On Wed, Aug 3, 2011 at 9:39 AM, mhorn <mark....@intel.com> wrote:
Try adding "-DANDROID" to your compile command line.

When you use the "ndk-build" script, it defines this macro.

It appears that the header file which sets 'size_t' requires that
macro to be defined.

I'll follow up if the header files needs to be changed to use a
different macro which is already defined by the standalone toolchain
(__ANDROID__) or if the standalone toolchain should also define the
ANDROID macro automatically.

The toolchain should only define __ANDROID__ automatically by all standalone toolchains

ANDROID is a macro that should, in theory, only used by the platform build (because at the time, we didn't have standalone toolchain at all, and we couldn't make our mind between using __ANDROID__ or ANDROID). In theory, anything related to the NDK should only use __ANDROID__ now.

mhorn

unread,
Aug 3, 2011, 11:37:13 AM8/3/11
to android-ndk
Bug filed:
http://code.google.com/p/android/issues/detail?id=19011


On Aug 3, 3:19 am, David Turner <di...@android.com> wrote:
Reply all
Reply to author
Forward
0 new messages