Bladeren bron

Ensure MIN/MAX overrides

Scott Lahteine 6 jaren geleden
bovenliggende
commit
f4c625d3a1
3 gewijzigde bestanden met toevoegingen van 16 en 14 verwijderingen
  1. 15
    12
      Marlin/src/core/minmax.h
  2. 1
    0
      Marlin/src/inc/MarlinConfig.h
  3. 0
    2
      frameworks/CMSIS/LPC1768/include/lpc_types.h

+ 15
- 12
Marlin/src/core/minmax.h Bestand weergeven

@@ -20,26 +20,29 @@
20 20
  *
21 21
  */
22 22
 
23
-#pragma once
24
-
25 23
 #undef MIN
26 24
 #undef MAX
27 25
 
28 26
 #ifdef __cplusplus
29 27
 
30
-  extern "C++" {
28
+  #ifndef _MINMAX_H_
29
+  #define _MINMAX_H_
30
+
31
+    extern "C++" {
32
+
33
+      // C++11 solution that is standards compliant. Return type is deduced automatically
34
+      template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
35
+        return lhs < rhs ? lhs : rhs;
36
+      }
37
+      template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
38
+        return lhs > rhs ? lhs : rhs;
39
+      }
40
+      template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
41
+      template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
31 42
 
32
-    // C++11 solution that is standards compliant. Return type is deduced automatically
33
-    template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
34
-      return lhs < rhs ? lhs : rhs;
35
-    }
36
-    template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
37
-      return lhs > rhs ? lhs : rhs;
38 43
     }
39
-    template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
40
-    template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
41 44
 
42
-  }
45
+  #endif
43 46
 
44 47
 #else
45 48
 

+ 1
- 0
Marlin/src/inc/MarlinConfig.h Bestand weergeven

@@ -43,5 +43,6 @@
43 43
 #include "../core/language.h"
44 44
 #include "../core/utility.h"
45 45
 #include "../core/serial.h"
46
+#include "../core/minmax.h"
46 47
 
47 48
 #endif // _MARLIN_CONFIG_H_

+ 0
- 2
frameworks/CMSIS/LPC1768/include/lpc_types.h Bestand weergeven

@@ -145,8 +145,6 @@ typedef int32_t(*PFI)();
145 145
 /* External data/function define */
146 146
 #define EXTERN extern
147 147
 
148
-#include "../../../../src/core/minmax.h"
149
-
150 148
 /**
151 149
  * @}
152 150
  */

Laden…
Annuleren
Opslaan