Page 1 of 1
new problem
Posted: Sat Jan 25, 2003 3:44 pm
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
Re:new problem
Posted: Sat Jan 25, 2003 5:00 pm
by whyme_t
have you defined the typedef size_t?
Re:new problem
Posted: Sat Jan 25, 2003 5:14 pm
by pskyboy
yep, unsigned long int
Re:new problem
Posted: Sat Jan 25, 2003 5:20 pm
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
Re:new problem
Posted: Sun Jan 26, 2003 9:12 am
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;
Re:new problem
Posted: Sun Jan 26, 2003 10:34 am
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
Re:new problem
Posted: Sun Jan 26, 2003 11:03 am
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.