Hello,
Toolchain arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi, downloaded from developer.arm.com/.../arm-gnu-toolchain-downloads
The following include:
#include <stdlib.h>
causes the error:
token "@" is not valid in preprocessor expressions
The reason is include/_newlib_version.h file, the Newlib version strings are defined as follows:
/* The newlib version in string format. */ #define _NEWLIB_VERSION "@NEWLIB_VERSION@" /* The newlib major version number. */ #define __NEWLIB__ @NEWLIB_MAJOR_VERSION@ /* The newlib minor version number. */ #define __NEWLIB_MINOR__ @NEWLIB_MINOR_VERSION@ /* The newlib patch level. */ #define __NEWLIB_PATCHLEVEL__ @NEWLIB_PATCHLEVEL_VERSION@
For the record, gcc-arm-11.2-2022.02-x86_64-arm-none-eabi has the following defines:
#define _NEWLIB_VERSION "4.1.0" #define __NEWLIB__ 4 #define __NEWLIB_MINOR__ 1 #define __NEWLIB_PATCHLEVEL__ 0
Hope this will be fixed soon.
Vadim Barshaw
My product uses FreeRTOS. I've found the library similar to what I am using, and which exhibits the problem. The steps to reproduce:
> git clone https://github.com/DRNadler/FreeRTOS_helpers.git > cd FreeRTOS_helpers > arm-none-eabi-gcc -c heap_useNewlib_ST.c In file included from /opt/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/arm-none-eabi/include/newlib.h:10, from /opt/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/arm-none-eabi/include/_ansi.h:10, from /opt/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/arm-none-eabi/include/stdlib.h:11, from heap_useNewlib_ST.c:69: heap_useNewlib_ST.c:76:7: error: token "@" is not valid in preprocessor expressions 76 | #if ((__NEWLIB__ == 2) && (__NEWLIB_MINOR__ < 5)) ||((__NEWLIB__ == 3) && (__NEWLIB_MINOR__ > 1)) | ^~~~~~~~~~ heap_useNewlib_ST.c:80:10: fatal error: FreeRTOS.h: No such file or directory 80 | #include "FreeRTOS.h" // defines public interface we're implementing here | ^~~~~~~~~~~~ compilation terminated. > arm-none-eabi-gcc --version arm-none-eabi-gcc (Arm GNU Toolchain 11.3.Rel1) 11.3.1 20220712 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Ignore the second error about missing FreeRTOS.h
I can reproduce this error now.
In a more recent internal development version, the token "@" error is not present, so it looks fixed.
Much appreciated!
This error is also present in gcc 12.2 toolchain.