Skip to content

Commit 04dc1fa

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

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

src/AsyncWebServerVersion.h

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