Closed maxgerhardt closed 2 years ago
Thanks for the report! We need to fix a build script and put macro to the right scope.
Regarding CCFLAGS
. I remember we had a problem with VSCode's C/C++ plugin if we pass GCC flags. So, we don't pass all compiler flags. The only flags related to the C/C++ preprocessed are passed.
So, we don't pass all compiler flags. The only flags related to the C/C++ preprocessed are passed.
But how about transforming known -D..
flags and putting them in the defines
section of the c_cpp_properties.json
? They don't have to be in the compiler arguments section. This fix would be more general and no build script adaptions needed.
An integrator decides on which scopes to put flags. We don't do any manipulation with flags. The correct solution is https://github.com/esp8266/Arduino/commit/c1144c5740406693808e92f072872260c7f069a0 because it also fixes ASM builds.
Thanks for the PR!
What kind of issue is this?
You can erase any parts of this template not applicable to your Issue.
Configuration
Operating system: Win 10 x64
PlatformIO Version (
platformio --version
): 6.0.2a2Description of problem
The PlatformIO core does not extract
-D<macro>
definitions fromCCFLAGS
into the e.g. VSCode Intellisensec_cpp_properties.json
. Only macros inCPPDEFINES
are.Steps to Reproduce
tzset();
insetup()
Actual Results
Intellisense does not know about this function and highlights it as error.
Expected Results
Intellisense knows about this function since
Arduino.h
is included which includestime.h
which saysIf problems with PlatformIO Build System:
The content of
platformio.ini
:Source file to reproduce issue:
Additional info
Intellisense does not recognize
tzset()
because that needs the_GNU_SOURCE
to be defined (which through a specific chain enables POSIX_VISIBLE). The Arduino-ESP8266 build process activates that macro throughCCFLAGS
here and it correctly shows up in the build commands. However, the.vscode/c_cpp_properties.json
does not have_GNU_SOURCE
in thedefines
section because-D
flags inCCFLAGS
is not considered during the generation of this file.I considered this fixing this by moving
-D
flags from CCFLAGS to CPPDEFINES, but this is then specific to Arduino-ESP8266. I think in general it would be good if the core is able to recognize this situation and relays the activated macros to the IDEs correctly. (See https://github.com/esp8266/Arduino/pull/8579).Also see community topic here and here.