Skip to content

Make sketch preprocessing optional #2406

Closed
@matthijskooijman

Description

@matthijskooijman

Right now, the IDE applies some preprocessing to sketches. In particular, it:

  1. Merges all .ino files
  2. Inserts #include <Arduino.h>
  3. Inserts forward declarations for functions

This preprocessing (especially point 3.) is messy and causes problems (#2304, #472, #386, #992, #455, #1735, #2289). We should work towards disabling it by default. The first step would be to make it optional (and allow a sketch author to opt-out of the preprocessing).
#1112 also suggested the same, using a #pragma line in the source file to do the opt-out. I don't really like using a #pragma, since it's scary looking (and I'd really like to encourage novice users to disable this as well, perhaps disable it by default on new sketches at some point).

I was thinking it would be a good idea to introduce some sketch metadata, e.g. add a sketch.properties (similar to library.properties) file to a sketch that can define some metadata, this flag and in the future perhaps also library options, compiler flags, etc. This file could then be edited through a GUI in the IDE.
#2324 already has some code to disable preprocessing based on a global preference (but that PR still needs some more cleanup).

Metadata

Metadata

Assignees

Labels

Component: PreprocessorThe Arduino sketch preprocessor converts .ino files into C++ code before compilation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions