Skip to content

Commit 3506bc3

Browse files
committed
Introduce AsyncWebServerVersion.h to more easily manage and use library version
1 parent 0ec6c7f commit 3506bc3

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

src/AsyncWebServerVersion.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: LGPL-3.0-or-later
2+
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
3+
4+
#pragma once
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
/** Major version number (X.x.x) */
11+
#define ASYNCWEBSERVER_VERSION_MAJOR 3
12+
/** Minor version number (x.X.x) */
13+
#define ASYNCWEBSERVER_VERSION_MINOR 6
14+
/** Patch version number (x.x.X) */
15+
#define ASYNCWEBSERVER_VERSION_PATCH 2
16+
17+
/**
18+
* Macro to convert version number into an integer
19+
*
20+
* To be used in comparisons, such as ASYNCWEBSERVER_VERSION >= ASYNCWEBSERVER_VERSION_VAL(2, 0, 0)
21+
*/
22+
#define ASYNCWEBSERVER_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
23+
24+
/**
25+
* Current version, as an integer
26+
*
27+
* To be used in comparisons, such as ASYNCWEBSERVER_VERSION_NUM >= ASYNCWEBSERVER_VERSION_VAL(2, 0, 0)
28+
*/
29+
#define ASYNCWEBSERVER_VERSION_NUM ASYNCWEBSERVER_VERSION_VAL(ASYNCWEBSERVER_VERSION_MAJOR, ASYNCWEBSERVER_VERSION_MINOR, ASYNCWEBSERVER_VERSION_PATCH)
30+
31+
/**
32+
* Current version, as string
33+
*/
34+
#define df2xstr(s) #s
35+
#define df2str(s) df2xstr(s)
36+
#define ASYNCWEBSERVER_VERSION df2str(ASYNCWEBSERVER_VERSION_MAJOR) "." df2str(ASYNCWEBSERVER_VERSION_MINOR) "." df2str(ASYNCWEBSERVER_VERSION_PATCH)
37+
38+
#ifdef __cplusplus
39+
}
40+
#endif

src/ESPAsyncWebServer.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,11 @@
4646
#error Platform not supported
4747
#endif
4848

49-
#include "literals.h"
50-
51-
#define ASYNCWEBSERVER_VERSION "3.6.2"
52-
#define ASYNCWEBSERVER_VERSION_MAJOR 3
53-
#define ASYNCWEBSERVER_VERSION_MINOR 6
54-
#define ASYNCWEBSERVER_VERSION_REVISION 2
5549
#define ASYNCWEBSERVER_FORK_ESP32Async
5650

51+
#include "AsyncWebServerVersion.h"
52+
#include "literals.h"
53+
5754
#ifdef ASYNCWEBSERVER_REGEX
5855
#define ASYNCWEBSERVER_REGEX_ATTRIBUTE
5956
#else

0 commit comments

Comments
 (0)