Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SENSOR_PUBLISH_ADDRESSES leads to compile-time error (Arduino IDE 1.8.15) #2594

Closed
CraigMarkwardt opened this issue Oct 9, 2023 · 1 comment
Labels

Comments

@CraigMarkwardt
Copy link
Contributor

Device

Wemos D1 Mini

Version

git commit 3a34f06

Question

I build with SENSOR_PUBLISH_ADDRESSES turned on. When I merged the newest code (git commit 3a34f06 dated Sept 22, 2023), I found the following build error
(Arduino IDE 1.8.15)

Arduino: 1.8.15 (Windows 10), Board: "LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"
...
In file included from C:\Users\craig\Documents\Arduino\espurna-pcc-ice-sensor\code\espurna\build.h:11,

                 from C:\Users\craig\Documents\Arduino\espurna-pcc-ice-sensor\code\espurna\espurna.h:29,

                 from C:\Users\craig\Documents\Arduino\espurna-pcc-ice-sensor\code\espurna\sensor.cpp:10:

C:\Users\craig\Documents\Arduino\espurna-pcc-ice-sensor\code\espurna\sensor.cpp: In function 'void espurna::sensor::magnitude::report(const espurna::sensor::Value&)':

types.h:398:42: error: '__pstr__' declared 'static' in 'constexpr' context

  398 |         alignas(4) static constexpr char __pstr__[] PROGMEM_STRING_ATTR = (X);\

      |                                          ^~~~~~~~

C:\Users\craig\Documents\Arduino\espurna-pcc-ice-sensor\code\espurna\sensor.cpp:1843:50: note: in expansion of macro 'STRING_VIEW'

 1843 |             static constexpr auto AddressTopic = STRING_VIEW(SENSOR_ADDRESS_TOPIC);

      |                                                  ^~~~~~~~~~~

The offending code is here in sensor.cpp:

#if SENSOR_PUBLISH_ADDRESSES
        {
            static constexpr auto AddressTopic = STRING_VIEW(SENSOR_ADDRESS_TOPIC);

            String address_topic;

I am not sure of the correct remedy, but removing "constexpr" does resolve the compiler error.

I have a feeling I'm the only person using sensor addresses, so this section of code hasn't been exercised in a while.

@mcspr
Copy link
Collaborator

mcspr commented Oct 16, 2023

I am not sure of the correct remedy, but removing "constexpr" does resolve the compiler error.

Running board version 3.1.2 should also fix the issue, updated compiler would understand the 'static constexpr' line correctly
Fixed in commit above via macro usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants