Skip to content

max() not accepting #defined values #6623

Closed
@palmerr23

Description

@palmerr23

Board

DevkitC ESP32 WROOM

Device Description

None

Hardware Configuration

No

Version

latest development Release Candidate (RC-X)

IDE Name

Arduino 1.8.13

Operating System

Win 11

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

Max is not accepting #defined values

The second call to max() fails to compile in ESP32, nut OK in AVR.

Issue occurs in both 2.0.2 and 2.0.3_RC1

Sketch

#define MULT 0.7
void setup() {
  float a = 1.1, b = 2.2, c;  
  c = max(a, b);
  c = max(a, MULT);
}

void loop() {
}

Debug Message

C:\Users\xyzzy.DESKTOP-J4ESB3N\Documents\dad\_microcontroller\esp\esp32\max_test\max_test.ino: In function 'void setup()':
max_test:5:17: error: no matching function for call to 'max(float&, double)'
   c = max(a,MULT);
                 ^
In file included from c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\algorithm:62,
                 from C:\Users\xyzzy.DESKTOP-J4ESB3N\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/Arduino.h:155,
                 from sketch\max_test.ino.cpp:1:
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algo.h:3468:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare)'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
C:\Users\xyzzy.DESKTOP-J4ESB3N\Documents\dad\_microcontroller\esp\esp32\max_test\max_test.ino:5:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'float'
   c = max(a,MULT);
                 ^
In file included from c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\algorithm:62,
                 from C:\Users\xyzzy.DESKTOP-J4ESB3N\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/Arduino.h:155,
                 from sketch\max_test.ino.cpp:1:
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algo.h:3462:5: note: candidate: 'template<class _Tp> _Tp std::max(std::initializer_list<_Tp>)'
     max(initializer_list<_Tp> __l)
     ^~~
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
C:\Users\xyzzy.DESKTOP-J4ESB3N\Documents\dad\_microcontroller\esp\esp32\max_test\max_test.ino:5:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'float'
   c = max(a,MULT);
                 ^
In file included from c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\algorithm:61,
                 from C:\Users\xyzzy.DESKTOP-J4ESB3N\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/Arduino.h:155,
                 from sketch\max_test.ino.cpp:1:
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algobase.h:265:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
C:\Users\xyzzy.DESKTOP-J4ESB3N\Documents\dad\_microcontroller\esp\esp32\max_test\max_test.ino:5:17: note:   deduced conflicting types for parameter 'const _Tp' ('float' and 'double')
   c = max(a,MULT);
                 ^
In file included from c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\algorithm:61,
                 from C:\Users\xyzzy.DESKTOP-J4ESB3N\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/Arduino.h:155,
                 from sketch\max_test.ino.cpp:1:
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algobase.h:219:5: note: candidate: 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
     max(const _Tp& __a, const _Tp& __b)
     ^~~
c:\users\xyzzy.desktop-j4esb3n\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
C:\Users\xyzzy.DESKTOP-J4ESB3N\Documents\dad\_microcontroller\esp\esp32\max_test\max_test.ino:5:17: note:   deduced conflicting types for parameter 'const _Tp' ('float' and 'double')
   c = max(a,MULT);

Other Steps to Reproduce

Nothing else, simple compile issue.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions