Page 1 of 1

Cross Compiler Causes memory functions to break.

Posted: Sun Dec 03, 2023 10:04 pm
by maxtyson123
My OS: https://github.com/maxtyson123/max-os/

When I am trying to override the new() functions etc I am getting an error saying the size parameter should be a 64 bit number even though the custom compiler targets 32bit:

Code: Select all

in file included from kernel/src/memory/memorymanagement.cpp:5:

kernel/include/memory/memorymanagement.h:78:7: error: 'operator new' takes type 'size_t' ('long unsigned int') as first parameter [-fpermissive]

78 | void* operator new(unsigned size);
I am wondering why this happens as when I try to compile it with my dist's gcc it works fine (after passing in the relevant 32bit parms)

Re: Cross Compiler Causes memory functions to break.

Posted: Sun Dec 03, 2023 10:56 pm
by Octocontrabass
maxtyson123 wrote:I am getting an error saying the size parameter should be a 64 bit number
No, you are getting an error saying the size parameter should be size_t. In your chosen ABI, size_t is equivalent to long unsigned int, which means in your chosen ABI, long unsigned int is 32 bits.

Your cross-compiler includes freestanding headers like stddef.h that include the correct definitions for standard types like size_t. Use those headers.