This is a followup to this thread on the raspberry pi forums. I'll summarize below.
Given a set of user C++ files, test.cpp and test.h, if #include "pico/float.h" is added to test.h, compilation fails due to '__builtin_choose_expr' was not declared in this scope, tracing to this set of lines in the SDK.
There is a workaround, if the extension of test.cpp is changed to test.c, compilation succeeds, even if the overall build environment is now mixed C/C++ (#ifdef __cplusplus extern "C" structures would also need to be added to test.c to prevent linking issues). Obviously this only helps if test.cpp didn't contain any C++ syntax in the first place.
So it seems some mode of compilation is controlled solely by the file extension, and the C++ mode isn't compiling float.h correctly. It looks like float.h contains the correct syntax for mixed-mode compilation, but beyond checking for that it's too far out of my expertise to give specific suggestions on the cause.
This is a followup to this thread on the raspberry pi forums. I'll summarize below.
Given a set of user C++ files, test.cpp and test.h, if
#include "pico/float.h"is added to test.h, compilation fails due to'__builtin_choose_expr' was not declared in this scope, tracing to this set of lines in the SDK.There is a workaround, if the extension of
test.cppis changed totest.c, compilation succeeds, even if the overall build environment is now mixed C/C++ (#ifdef __cplusplus extern "C"structures would also need to be added totest.cto prevent linking issues). Obviously this only helps iftest.cppdidn't contain any C++ syntax in the first place.So it seems some mode of compilation is controlled solely by the file extension, and the C++ mode isn't compiling float.h correctly. It looks like float.h contains the correct syntax for mixed-mode compilation, but beyond checking for that it's too far out of my expertise to give specific suggestions on the cause.