Check for constinit support

This commit is contained in:
blankie 2023-05-12 17:23:26 +07:00
parent c37080d85a
commit 43446801b3
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 7 additions and 1 deletions

View File

@ -134,7 +134,13 @@ static const constexpr char css[] = R"EOF(
)EOF";
#define CSS_LEN sizeof(css) / sizeof(css[0]) - 1
constinit const uint64_t css_hash = FastHash(css, CSS_LEN, 0);
#if __cpp_constinit
#define CONSTINIT constinit
#else
#define CONSTINIT
#endif
CONSTINIT const uint64_t css_hash = FastHash(css, CSS_LEN, 0);
void css_route(const httplib::Request& req, httplib::Response& res) {
res.set_header("ETag", std::string(1, '"') + std::to_string(css_hash) + '"');