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

Compiler warning when build with PIO, redefine of struct_size in main.ino #917

Closed
AlmightyFrog opened this issue Apr 5, 2021 · 2 comments · Fixed by #1010
Closed

Compiler warning when build with PIO, redefine of struct_size in main.ino #917

AlmightyFrog opened this issue Apr 5, 2021 · 2 comments · Fixed by #1010
Milestone

Comments

@AlmightyFrog
Copy link

It is not nice to see a warning at each fresh build, but it seems to be a wrong warning...

Describe the bug
It seems that there is something strange ongoing at converting that main.ino to main.ino.cpp giving a warning:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.1.1) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10005.210308 (1.0.5) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
Converting main.ino
/mypath/OpenMQTTGateway-REF/main/main.ino:41:0: warning: "struct_size" redefined
 #    define struct_size 4
 ^
/mypath/OpenMQTTGateway-REF/main/main.ino:38:0: note: this is the location of the previous definition
 #    define struct_size 12
 ^

Here you can see the corresponding code after converting, which seems totally fine to me:

# if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
#define struct_size 12
ReceivedSignal receivedSignal[struct_size] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
# else
#define struct_size 4
ReceivedSignal receivedSignal[struct_size] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
# endif
#endif

It pretty much just removes the comments and some excessive whitespaces.

To Reproduce
Just type pio run and when it is compiling look at the output.
If you want to compare the original main.ino with the temporary main.ino.cpp just make sure to save or use it until it is remved when compile is finished.

I directly opened it with a diff tool like meld main.ino main.ino.cpp in another shell.

Environment (please complete the following information):
Latest version development.

@dkneisz
Copy link
Contributor

dkneisz commented May 6, 2021

@NorthernMan54
Copy link
Collaborator

This is a potential workaround

#    ifdef struct_size
#      undef struct_size
#    endif

ie

#    define struct_size 12
ReceivedSignal receivedSignal[struct_size] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
#  else // boards with smaller memory
#    ifdef struct_size
#      undef struct_size
#    endif
#    define struct_size 4
ReceivedSignal receivedSignal[struct_size] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
#  endif

@1technophile 1technophile added this to the v0.9.7 milestone Jun 9, 2021
h2zero added a commit to h2zero/OpenMQTTGateway that referenced this issue Jul 6, 2021
@h2zero h2zero mentioned this issue Jul 6, 2021
3 tasks
h2zero added a commit to h2zero/OpenMQTTGateway that referenced this issue Jul 6, 2021
1technophile pushed a commit that referenced this issue Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants