Skip to content

Commit 3b3372d

Browse files
committed
cores: replace max and min macros with imports from std
fixes #1734
1 parent 80c110e commit 3b3372d

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

Diff for: cores/esp32/Arduino.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
146146
#ifdef __cplusplus
147147
}
148148

149+
#include <algorithm>
150+
149151
#include "WCharacter.h"
150152
#include "WString.h"
151153
#include "Stream.h"
@@ -158,6 +160,11 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
158160
#include "HardwareSerial.h"
159161
#include "Esp.h"
160162

163+
using std::isinf;
164+
using std::isnan;
165+
using std::max;
166+
using std::min;
167+
161168
uint16_t makeWord(uint16_t w);
162169
uint16_t makeWord(byte h, byte l);
163170

@@ -176,12 +183,6 @@ extern "C" void configTzTime(const char* tz,
176183
long random(long);
177184
#endif /* __cplusplus */
178185

179-
#ifndef _GLIBCXX_VECTOR
180-
// arduino is not compatible with std::vector
181-
#define min(a,b) ((a)<(b)?(a):(b))
182-
#define max(a,b) ((a)>(b)?(a):(b))
183-
#endif
184-
185186
#define _min(a,b) ((a)<(b)?(a):(b))
186187
#define _max(a,b) ((a)>(b)?(a):(b))
187188

Diff for: libraries/WiFi/src/WiFiClient.h

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
#include "Arduino.h"
2525
#include "Client.h"
26-
#undef min
27-
#undef max
2826
#include <memory>
2927

3028
class WiFiClientSocketHandle;

Diff for: libraries/WiFi/src/WiFiGeneric.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ extern "C" {
4646
} //extern "C"
4747

4848
#include "esp32-hal-log.h"
49-
50-
#undef min
51-
#undef max
5249
#include <vector>
5350

5451
#include "sdkconfig.h"
@@ -156,8 +153,8 @@ static bool espWiFiStart(bool persistent){
156153
return false;
157154
}
158155
_esp_wifi_started = true;
159-
system_event_t event;
160-
event.event_id = SYSTEM_EVENT_WIFI_READY;
156+
system_event_t event;
157+
event.event_id = SYSTEM_EVENT_WIFI_READY;
161158
WiFiGenericClass::_eventCallback(nullptr, &event);
162159

163160
return true;
@@ -496,7 +493,7 @@ bool WiFiGenericClass::mode(wifi_mode_t m)
496493
} else if(cm && !m){
497494
return espWiFiStop();
498495
}
499-
496+
500497
esp_err_t err;
501498
err = esp_wifi_set_mode(m);
502499
if(err){

Diff for: libraries/WiFi/src/WiFiMulti.h

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#define WIFICLIENTMULTI_H_
2828

2929
#include "WiFi.h"
30-
#undef min
31-
#undef max
3230
#include <vector>
3331

3432
typedef struct {

0 commit comments

Comments
 (0)