Skip to content

c and h source file are preprocessed while they should not #363

Closed
@fpistm

Description

@fpistm

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:

  1. Install IDE 2.0 Beta 5
  2. Install STM32 core version 2.0.0 (https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json)
  3. Add a build_opt.h file containing the line -DHAL_CRC_MODULE_ENABLED
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions