From c37bc2d0053d4602cec4fc2d788dc5d7dc4c567c Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Sat, 11 Jul 2026 21:46:53 +0200 Subject: [PATCH] viewer/curl: keep out of JFJochHttpReader.h (MSVC build fix) curl.h transitively includes , whose min/max/ERROR/LoadImage macros clobbered every viewer TU that includes this widely-used header (std::min/max in gemmi, the TaskState::ERROR enum, the LoadImage() calls, the Qt/fftw cascade). It even broke JFJochHttpReader.cpp itself, since inside the header curl.h preceded the reader/common includes that pull in gemmi. Forward-declare the opaque easy handle (CURL is `typedef void` in libcurl) so the header no longer needs curl.h, and include curl.h only in the .cpp, last, after all std/project headers. Co-Authored-By: Claude Opus 4.8 --- viewer/JFJochHttpReader.cpp | 5 ++++- viewer/JFJochHttpReader.h | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/viewer/JFJochHttpReader.cpp b/viewer/JFJochHttpReader.cpp index 7103ad5e..8f15f1c4 100644 --- a/viewer/JFJochHttpReader.cpp +++ b/viewer/JFJochHttpReader.cpp @@ -3,7 +3,6 @@ #include "JFJochHttpReader.h" -#include #include #include #include @@ -15,6 +14,10 @@ #include "../common/JFJochMath.h" #include "../image_analysis/bragg_integration/CalcISigma.h" +// Included last, after all std/project headers: on Windows pulls in , +// whose min/max (and other) macros must not precede the headers that use std::min / std::max. +#include + namespace { // libcurl write callback: append the received bytes to a std::string (which holds binary fine). size_t AppendToString(char *ptr, size_t size, size_t nmemb, void *userdata) { diff --git a/viewer/JFJochHttpReader.h b/viewer/JFJochHttpReader.h index 3dbbd122..d973dc4c 100644 --- a/viewer/JFJochHttpReader.h +++ b/viewer/JFJochHttpReader.h @@ -3,13 +3,18 @@ #pragma once -#include - #include "../reader/JFJochReader.h" #include "../common/BrokerStatus.h" #include "../common/ImageBuffer.h" #include "../common/ROIDefinition.h" +// libcurl's easy handle, kept opaque here so this widely-included header does NOT pull in +// . On Windows curl.h drags in , whose min/max/ERROR/LoadImage macros +// would then clobber every viewer translation unit that includes this header (breaking std::min / +// std::max in gemmi, the `ERROR` enum, the LoadImage() calls, ...). CURL is `typedef void` in +// libcurl; is included only in JFJochHttpReader.cpp. +using CURL = void; + class JFJochHttpReader : public JFJochReader { mutable std::mutex http_mutex; std::string addr;