Trouble Building Code On MacOS : error: narrowing conversion of 'fmax(fmax(((double)magVar.Vector3<float>::x),

Hi,
I am trying to build the code on my MacOS and followed everything as mentioned on the official build environment setup document on Setting up the Build Environment (MacOSX) — Dev documentation

But when I try to build with ./waf --targets bin/arducopter I get below error in the end:

<div style="background:#eee;padding:20px;">In file included from ../../libraries/AP_Math/matrix3.h:40:0,
                 from ../../libraries/AP_Math/AP_Math.h:13,
                 from ../../libraries/AP_Common/Location.h:3,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3.h:22,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3_Outputs.cpp:3:
../../libraries/AP_NavEKF3/AP_NavEKF3_Outputs.cpp: In member function 'void NavEKF3_core::send_status_report(GCS_MAVLINK&) const':
../../libraries/AP_Math/ftype.h:24:24: error: narrowing conversion of 'fmax(fmax(((double)magVar.Vector3<float>::x), ((double)magVar.Vector3<float>::y)), ((double)magVar.Vector3<float>::z))' from 'double' to 'float' inside { } [-Werror=narrowing]
 #define fmaxF(x,y) fmax(x,y)
                        ^
../../libraries/AP_NavEKF3/AP_NavEKF3_Outputs.cpp:622:9: note: in expansion of macro 'fmaxF'
         fmaxF(fmaxF(magVar.x,magVar.y),magVar.z),
         ^
compilation terminated due to -Wfatal-errors.
cc1plus: some warnings being treated as errors

../../libraries/AP_NavEKF3/AP_NavEKF3_core.cpp: In member function 'void NavEKF3_core::CovariancePrediction(Vector3F*)':
../../libraries/AP_NavEKF3/AP_NavEKF3_core.cpp:1806:1: warning: the frame size of 2112 bytes is larger than 1300 bytes [-Wframe-larger-than=]
 }
 ^
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-expansion-to-defined'</div>

I am new to the field and really sorry if I am missing something basic here, but any help is appreciated. Not sure where to go from here.

2 Likes

I got this same error.
Mac, M2, Monterey, 12.5.1

This could help :wink: --ekf-single

Can confirm, experiencing the same issue on a M2 Mac, --ekf-single does fix it, but is there any alternative?