Skip to content

Arduino.h: error on max macro definition #1734

Closed
@Sauro98

Description

@Sauro98

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: up to date as of 06/08/2018
IDE name: VSCode
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

I am working with a TTGO esp32 module and I'm using vectors in my code, and it compiled fine up to a certain point. Then, out of the blue, it suddenly started giving me this error when trying to upload the code to the board:

c:\users\ivano\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_vector.h: 
In member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::_M_check_len(std::vector<_Tp, _Alloc>::size_type, const char*) const':

C:\Users\Ivano\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:182:18: error: expected unqualified-id before '(' token

 #define max(a,b) ((a)>(b)?(a):(b))

To get it to compile again I had to undefine min and max after including Arduino.h

#include <Arduino.h>
#undef min
#undef max

It might be worth noting that I'm also including vector in another file but commenting that include out did not change the problem.

Is there a reason why this should happen?

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