new problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pskyboy

new problem

Post by pskyboy »

Hey Guys

I have written my own new operator but when i try and compile i get an error:-
new takes type size_t as first parameter
I have got
-ffreestanding -fno-exceptions -fnostdlib -fno-builtin
all set so i don't know why it won't work

cheers
Peter
whyme_t

Re:new problem

Post by whyme_t »

have you defined the typedef size_t?
pskyboy

Re:new problem

Post by pskyboy »

yep, unsigned long int
whyme_t

Re:new problem

Post by whyme_t »

Code: Select all

typedef unsigned long int size_t ;
extern "C" void* operator new(size_t t)
{
    //call to your alloc function
}
This compiles ok for me with these gxx switches
-ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions
Tim

Re:new problem

Post by Tim »

...or you could just define size_t the same way that gcc expects and dispense with all those command-line options:

typedef unsigned int size_t;
pskyboy

Re:new problem

Post by pskyboy »

Cheers it works now

i hadn't assigned size_t properly and so it was throwing up errors.

i had defined it as unsigned which obvioulsy would cause problems

cheers anyway
Peetr
whyme_t

Re:new problem

Post by whyme_t »

Tim Robinson wrote: ...or you could just define size_t the same way that gcc expects and dispense with all those command-line options:

typedef unsigned int size_t;
The command-line options aren't to get that code to compile, but to be able to compile C++ source which will run without run time support.
Post Reply