Skip to content

Commit effdc65

Browse files
committed
retarget: Added workaround for conflicting definitions of error_t
The errno.h header file defines the type error_t, unfortunately this is a common type name that may be defined in user code. For at least GCC we can work around this by telling errno that the error_t is already defined.
1 parent 78992a4 commit effdc65

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

platform/mbed_retarget.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
#endif //__cplusplus
2727
#include <stdint.h>
2828
#include <stddef.h>
29+
30+
/* Include logic for errno so we can get errno defined but not bring in error_t,
31+
* including errno here prevents an include later, which would redefine our
32+
* error codes
33+
*/
34+
#ifndef __error_t_defined
35+
#define __error_t_defined 1
2936
#include <errno.h>
37+
#undef __error_t_defined
38+
#else
39+
#include <errno.h>
40+
#endif
3041

3142
/* We can get the following standard types from sys/types for gcc, but we
3243
* need to define the types ourselves for the other compilers that normally

0 commit comments

Comments
 (0)