Skip to content

Commit 989a0f1

Browse files
fix: guard HTTP_ANY undef/alias with ASYNCWEBSERVER_NO_HTTP_ANY opt-out
Co-authored-by: mathieucarbou <61346+mathieucarbou@users.noreply.github.com>
1 parent d36b720 commit 989a0f1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/ESPAsyncWebServer.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,17 @@ extern constexpr inline WebRequestMethodComposite operator|(WebRequestMethod l,
117117
// reference like AsyncWebRequestMethod::HTTP_ANY would be incorrectly expanded to AsyncWebRequestMethod::0.
118118
// To avoid this conflict, HTTP_ANY is provided here as a C++ constexpr (not a macro), after undefining
119119
// any previously defined HTTP_ANY macro. Use HTTP_ALL as the canonical non-conflicting name.
120-
#ifdef HTTP_ANY
121-
#undef HTTP_ANY
122-
#endif
120+
// To suppress this behavior entirely (keeping any pre-existing HTTP_ANY macro and not providing the alias),
121+
// define ASYNCWEBSERVER_NO_HTTP_ANY before including this header.
122+
#if !defined(ASYNCWEBSERVER_NO_HTTP_ANY)
123+
#ifdef HTTP_ANY
124+
#warning "HTTP_ANY macro is already defined and will be undefined to avoid conflicts with ESPAsyncWebServer. To suppress this and keep the original macro, define ASYNCWEBSERVER_NO_HTTP_ANY and use AsyncWebRequestMethod::HTTP_ALL instead."
125+
#undef HTTP_ANY
126+
#endif
123127
namespace AsyncWebRequestMethod {
124128
static constexpr AsyncWebRequestMethodType HTTP_ANY = HTTP_ALL;
125129
} // namespace AsyncWebRequestMethod
130+
#endif
126131

127132
#if !defined(ASYNCWEBSERVER_NO_GLOBAL_HTTP_METHODS)
128133
// Import the method enum values to the global namespace

0 commit comments

Comments
 (0)