Skip to content

Export CCFLAGS macros to IntelliSense #275

Closed
@maxgerhardt

Description

@maxgerhardt

What kind of issue is this?

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.

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.2a2

Description of problem

The PlatformIO core does not extract -D<macro> definitions from CCFLAGS into the e.g. VSCode Intellisense c_cpp_properties.json. Only macros in CPPDEFINES are.

Steps to Reproduce

  1. Create a new Nodemcuv2 + Arduino (ESP8266) project
  2. Add a call to tzset(); in setup()

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 includes time.h which says

#if __POSIX_VISIBLE
void      tzset 	(void);
#endif

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino

Source file to reproduce issue:

#include <Arduino.h>
#include <string.h>
#include <string>

void setup() {}
void loop()
{
    const char *s = "test";
    char buf[64];
    strlcpy(buf, s, sizeof(buf));

    setenv("TZ", "CST-8", 1);
    tzset();

    int res = strcasecmp("A", "a");
}

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 through CCFLAGS here and it correctly shows up in the build commands. However, the .vscode/c_cpp_properties.json does not have _GNU_SOURCE in the defines section because -D flags in CCFLAGS 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 esp8266/Arduino#8579).

Also see community topic here and here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions