Description
Describe the bug
STM32 core allows user to define some value by adding a build_opt.h file at sketch level.
This file is not a standard header file as it is used by the gcc command line with @file
option.
https://github.com/stm32duino/wiki/wiki/Customize-build-options-using-build_opt.h
To achieve this a simple recipe hooks prebuild is used. When no file exists at sketch level it creates an empty one.
It works fine with Arduino 1.8.x (until 1.8.13 seems 1.8.15 embed the same behaviour)
.h
file extension has been used because Arduino 1.8.x does not allow to create file without a specific extension (ino, c, cpp, h, hpp).
But with Arduino IDE Beta 5, this file is preprocessed (seems like the ino file) and add extra line which cause issue to gcc.
For example a build_opt.h with:
-DHAL_CRC_MODULE_ENABLED
is converted to:
#line 1 "c:\\Users\\<username>\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2021410-37444-aykylf.uyhtw\\sketch_may10a\\build_opt.h"
-DHAL_CRC_MODULE_ENABLED
Below the build result due to the #line
addition:
arm-none-eabi-g++: error: #line: No such file or directory
arm-none-eabi-g++: error: 1: No such file or directory
Compilation error: Error: 2 UNKNOWN: exit status 1
To Reproduce
Steps to reproduce the behavior:
- Install IDE 2.0 Beta 5
- Install STM32 core version 2.0.0 (https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json)
- Add a
build_opt.h
file containing the line-DHAL_CRC_MODULE_ENABLED
- attempt to verify
Expected behavior
Do not preprocess file and able to build.
Desktop (please complete the following information):
- OS: all
- Version: [e.g. 2.0.0]: 2.0.0 Beta 5
Additional context
It seems that all created files are also preprocess: c, cpp,...
Issue originally reported by an user here:
stm32duino/Arduino_Core_STM32#1387