forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/newlib: revert treatment of libc files as system includes
The solution from zephyrproject-rtos#14312 of using -isystem to prioritize the position of the libc directory bypasses the effect of -ffreestanding with respect to libc symbols expected to be present in a non-hosted environment. Further, it breaks C++ with the ARM Embedded toolchain as the system fails to find the right file with #include_next. Use a more fine-grained solution that explicitly includes the underlying newlib header required for <inttypes.h> support before moving on to include the next available one, whether system or non-system. Closes zephyrproject-rtos#17564 Signed-off-by: Peter Bigot <[email protected]>
- Loading branch information
Showing
2 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2019 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STDINT_H_ | ||
#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STDINT_H_ | ||
|
||
/* Work around -ffreestanding absence of defines required to support | ||
* PRI.64 macros in <inttypes.h> by including the newlib header that | ||
* provides the flag macros. | ||
*/ | ||
|
||
#include <newlib.h> | ||
|
||
#ifdef __NEWLIB__ | ||
/* Has this header. Older versions do it in <stdint.h>. */ | ||
#include <sys/_stdint.h> | ||
#endif /* __NEWLIB__ */ | ||
|
||
/* This should work on GCC and clang. | ||
* | ||
* If we need to support a toolchain without #include_next the CMake | ||
* infrastructure should be used to identify it and provide an | ||
* alternative solution. | ||
*/ | ||
#include_next <stdint.h> | ||
|
||
#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STDINT_H_ */ |