Skip to content

Commit d2e137f

Browse files
etrclaude
andcommitted
Fix CI: cpplint include order in http_utils.cpp + Windows ERROR macro clash
Two unrelated CI regressions on PR #374, both falling out of TASK-020: 1. Lint job (gcc-14, ubuntu): cpplint flagged src/http_utils.cpp:30 with build/include_order, because the matching public header ("httpserver/http_utils.hpp") came AFTER a non-matching project header ("httpserver/constants.hpp"), and <microhttpd.h> (a C system header in cpplint's view) followed both. cpplint's expected order is: matching header, C system, C++ system, other. Reorder so the matching header comes first and the project headers ("constants.hpp" / "string_utilities.hpp") move to the bottom of the include block. 2. Windows MSYS2 build: src/httpserver/http_utils.hpp failed with error: expected identifier before numeric constant at the line `ERROR = 0,` inside the digest_auth_result enum. <wingdi.h> (pulled in via <windows.h> via <winsock2.h> via <microhttpd.h> on MinGW) unconditionally `#define`s ERROR to 0, and the preprocessor expands macros inside scoped-enum bodies just like anywhere else. Pre-TASK-020 the enum was inside `#ifdef HAVE_DAUTH`, so MSYS2 builds without digest auth never compiled it; PRD-FLG-REQ-001 then made the enum unconditional and exposed the latent collision. v2.0 is unreleased, so renaming is safe: ERROR -> GENERIC_ERROR (matches MHD_DAUTH_ERROR's "general error" docs). Static-assert pin in src/http_utils.cpp updated to match. Verified locally: - python3 -m cpplint on both touched files: exit 0. - `make check` on macOS: 32/32 PASS, all check-hygiene / check-headers gates PASS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0d82a50 commit d2e137f

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/http_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
USA
1919
*/
2020

21-
#include "httpserver/constants.hpp"
2221
#include "httpserver/http_utils.hpp"
2322

2423
// TASK-020: <microhttpd.h> is no longer pulled in transitively by
@@ -57,6 +56,7 @@
5756
#include <utility>
5857
#include <vector>
5958

59+
#include "httpserver/constants.hpp"
6060
#include "httpserver/string_utilities.hpp"
6161

6262
#pragma GCC diagnostic ignored "-Warray-bounds"
@@ -634,8 +634,8 @@ static_assert(
634634
static_cast<int>(http_utils::digest_auth_result::OK) == MHD_DAUTH_OK,
635635
"digest_auth_result::OK diverged from MHD_DAUTH_OK");
636636
static_assert(
637-
static_cast<int>(http_utils::digest_auth_result::ERROR) == MHD_DAUTH_ERROR,
638-
"digest_auth_result::ERROR diverged from MHD_DAUTH_ERROR");
637+
static_cast<int>(http_utils::digest_auth_result::GENERIC_ERROR) == MHD_DAUTH_ERROR,
638+
"digest_auth_result::GENERIC_ERROR diverged from MHD_DAUTH_ERROR");
639639
static_assert(
640640
static_cast<int>(http_utils::digest_auth_result::WRONG_HEADER) == MHD_DAUTH_WRONG_HEADER,
641641
"digest_auth_result::WRONG_HEADER diverged from MHD_DAUTH_WRONG_HEADER");

src/httpserver/http_utils.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ class http_utils {
152152

153153
enum class digest_auth_result {
154154
OK = 1, // MHD_DAUTH_OK
155-
ERROR = 0, // MHD_DAUTH_ERROR
155+
// GENERIC_ERROR (not "ERROR") because <wingdi.h> on Windows
156+
// unconditionally `#define`s ERROR to 0, which the preprocessor
157+
// expands inside scoped-enum bodies just like anywhere else.
158+
GENERIC_ERROR = 0, // MHD_DAUTH_ERROR ("general error")
156159
WRONG_HEADER = -1, // MHD_DAUTH_WRONG_HEADER
157160
WRONG_USERNAME = -2, // MHD_DAUTH_WRONG_USERNAME
158161
WRONG_REALM = -3, // MHD_DAUTH_WRONG_REALM

0 commit comments

Comments
 (0)