diff --git a/libraries/AP_Common/AP_MetaClass.h b/libraries/AP_Common/AP_MetaClass.h index b46f4308d1..1025fad962 100644 --- a/libraries/AP_Common/AP_MetaClass.h +++ b/libraries/AP_Common/AP_MetaClass.h @@ -108,7 +108,7 @@ public: /// @return An opaque handle /// Meta_handle meta_get_handle(void) const { - return ((Meta_handle)meta_type_id() << 16) | (uint16_t)this; + return ((Meta_handle)meta_type_id() << 16) | (uintptr_t)this; } /// Validates an AP_Meta_class handle. @@ -134,7 +134,7 @@ public: // Note that this implies that we cannot deal with objects in ROM or EEPROM, // but the constructor wouldn't be able to populate a vtable pointer there anyway... // - if ((uint16_t)candidate >= (RAMEND - 2)) { // -2 to account for the type_id + if ((uintptr_t)candidate >= (RAMEND - 2)) { // -2 to account for the type_id return NULL; } diff --git a/libraries/AP_Common/c++.cpp b/libraries/AP_Common/c++.cpp index c1307ea13f..e2fc437a2f 100644 --- a/libraries/AP_Common/c++.cpp +++ b/libraries/AP_Common/c++.cpp @@ -78,10 +78,10 @@ int freeMemory() { int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); + if ((intptr_t)__brkval == 0) + free_memory = ((intptr_t)&free_memory) - ((intptr_t)&__bss_end); else - free_memory = ((int)&free_memory) - ((int)__brkval); + free_memory = ((intptr_t)&free_memory) - ((intptr_t)__brkval); return free_memory; }