Skip to content

Compilation with float.h in a *.cpp file fails #2916

@AwFiddlesticks

Description

@AwFiddlesticks

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions