Static_assert asserting when true

During compile I am getting a static assert error for this static_assert. Yet, the IDE tells me that the evaluation should be true (‘0 == 0’) and thus should ignore the static assert…


C:/Users/me/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h:719:41: error: static assertion failed: portGET_ARGUMENT_COUNT() result does not match for 0 arguments
_Static_assert(portGET_ARGUMENT_COUNT() == 0, “portGET_ARGUMENT_COUNT() result does not match for 0 arguments”);

and here is the definition of portGET_ARGUMENT_COUNT

#define portGET_ARGUMENT_COUNT(...) portGET_ARGUMENT_COUNT_INNER(0, ##__VA_ARGS__,1,0)

What is the platformio.ini and code with which you can trigger this assert?

platform = espressif32
board = m5stack-core2
framework = arduino
platform_packages =
framework-arduinoespressif32@GitHub - espressif/arduino-esp32: Arduino core for the ESP32
build_flags = -std=c++14
build_unflags = -std=gnu++11

the code for the assert is as shown above during compile:

#define portGET_ARGUMENT_COUNT(...) portGET_ARGUMENT_COUNT_INNER(0, ##__VA_ARGS__,1,0)
#define portGET_ARGUMENT_COUNT_INNER(zero, one, count, ...) count

_Static_assert(portGET_ARGUMENT_COUNT() == 0, "portGET_ARGUMENT_COUNT() result does not match for 0 arguments");

This has become outdated with newer Arduino-ESP32 versions (referencing a direct .git link without a tag or commit hash is unstable). You should try and use the platformio.ini per this

platform =
board = m5stack-core2
framework = arduino
platform_packages =
   framework-arduinoespressif32 @
build_flags = -std=c++14
build_unflags = -std=gnu++11

I have modified my platformio.ini as requested (with a typo fix where you doubled the ‘framework-arduinoespressif32@’ in platform packages) but I get the same result with the compiler spitting out the same static assert error.

Intellisense still tells me that the _Static_assert expands to 0 == 0.

What is the code inside your src/ folder?

Does the same error occur when you’re using only the blinky code?

I’m attempting port a library ( for use with my device so I’m not sure how much help diving into my code will be but here it is:

#include <Arduino.h>
#include <DiscoveryManager.h>
#include <utils/Logger.h>
#include <string>
#include <stdlib.h>

using eipScanner::DiscoveryManager;
using eipScanner::utils::Logger;
using eipScanner::utils::LogLevel;

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

I didn’t want to go too far into the weeds on the forum since it is a fairly large library and the code pertaining to the static assert firing when it shouldn’t seemed fairly straight forward.

Well I’ve read portmacro.h and specifically

Macro to count number of arguments of a VA_ARGS used to support portYIELD_FROM_ISR with,
The first one is using the GNU extension ##VA_ARGS. The second one is using the C++20 feature VA_OPT(,).

The keyword is GNU (language) extension here. You explicitly kill off GNU++11 and replace it with C++14 (without GNU extensions)

If I replace the first one with

build_flags = -std=gnu++14

successful compilation is restored again.


Thank you!