Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions user/inc/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ typedef volatile uint32_t RwReg;
// C++ only
#ifdef __cplusplus

#ifndef __clang__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest also not using targeting __clang__ specifically and instead include <cmath> if compiling as __cplusplus and math.h otherwise, which should resolve the problem.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Note that my fix still includes math.h in all cases since I think that's required for backwards compatibility with user code as described in the new comment. My C experience is limited so I'm prepared to be wrong about that!

I also chose to put the conditional include of <cmath> adjacent to the include of math.h since I think it's clearer even though it requires a separate #ifndef __cplusplus guard.

// Under clang, "math.h" does not put isnan/isinf inside the std namespace so this would fail

#ifndef isnan
using std::isnan;
#endif
Expand All @@ -201,6 +204,7 @@ using std::isnan;
using std::isinf;
#endif

#endif // __clang__

// Hardware serial defines

Expand Down
5 changes: 5 additions & 0 deletions wiring/src/spark_wiring_usbserial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
******************************************************************************
*/

#ifdef __clang__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to be __clang__-specific.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

// Needed for std::{min,max} in Clang
#include <algorithm>
#endif

#include "spark_wiring_usbserial.h"
#include "platform_headers.h"

Expand Down