diff --git a/platforms/common/include/px4_platform_common/posix.h b/platforms/common/include/px4_platform_common/posix.h index b1cada1019..8b8c16069f 100644 --- a/platforms/common/include/px4_platform_common/posix.h +++ b/platforms/common/include/px4_platform_common/posix.h @@ -131,7 +131,14 @@ __END_DECLS // we often run out of stack space when pointers are larger than 4 bytes. // Double the stack size on posix when we're on a 64-bit architecture. // Most full-scale OS use 1-4K of memory from the stack themselves -#define PX4_STACK_ADJUSTED(_s) ((_s) * (sizeof(void *) >> 2) + PX4_STACK_OVERHEAD) +#ifndef __SIZEOF_POINTER__ +# if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_X64)) +# define __SIZEOF_POINTER__ 8 +# else +# define __SIZEOF_POINTER__ 4 +# endif +#endif +#define PX4_STACK_ADJUSTED(_s) ((_s) * (__SIZEOF_POINTER__ >> 2) + PX4_STACK_OVERHEAD) __BEGIN_DECLS