Skip to content

Fix 32-bit MSVC compiler error due to unknown command #warning#2202

Merged
yhirose merged 1 commit into
yhirose:masterfrom
thbeu:fix-c1021
Aug 12, 2025
Merged

Fix 32-bit MSVC compiler error due to unknown command #warning#2202
yhirose merged 1 commit into
yhirose:masterfrom
thbeu:fix-c1021

Conversation

@thbeu

@thbeu thbeu commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

Resolves #2201

@thbeu thbeu changed the title #2201 Fix 32-bit MSVC compiler error due to unknown command #warning Fix 32-bit MSVC compiler error due to unknown command #warning Aug 8, 2025
Comment thread httplib.h
@yhirose

yhirose commented Aug 10, 2025

Copy link
Copy Markdown
Owner

@thbeu how about this? It's simpler and no code duplication.

/*
 * Platform compatibility check
 */

#if defined(_WIN32) && !defined(_WIN64)
#if defined(_MSC_VER)
#pragma message(                                                               \
    "cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler.")
#else
#warning                                                                       \
    "cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler."
#endif
#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ < 8
#warning                                                                       \
    "cpp-httplib doesn't support 32-bit platforms. Please use a 64-bit compiler."
#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ < 8
#warning                                                                       \
    "cpp-httplib doesn't support platforms where size_t is less than 64 bits."
#endif

@yhirose

yhirose commented Aug 11, 2025

Copy link
Copy Markdown
Owner

Could you please show me what error you get when you run my suggested code with v0.25.0 MSVC on your machine?

@thbeu

thbeu commented Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

Could you please show me what error you get when you run my suggested code with v0.25.0 MSVC on your machine?

Builds as expected (with one warning C4244 though).

MSBuild-Version 17.14.18+a338add32 für .NET Framework

  1>Checking Build System
  Building Custom Rule C:/Users/thbeu/source/repos/cpp-httplib/CMakeLists.txt
  httplib.cc
  cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler.
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244: "Initialisierung": Konvertierung von "_Ty" in "_Ty1", möglicher Datenverlust [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:         with [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:         [ [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:             _Ty=__int64 [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:         ] [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:         and [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:         [ [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:             _Ty1=size_t [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16): warning C4244:         ] [C:\Users\thbeu\source\repos\cpp-httplib\build2\httplib.vcxproj]
  (Quelldatei „out/httplib.cc“ wird kompiliert)
      C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\utility(303,16):
      der Vorlageninstanziierungskontext (der älteste zuerst) ist
          C:\Users\thbeu\source\repos\cpp-httplib\build2\out\httplib.cc(3292,24):
          Siehe Verweis auf die gerade kompilierte Instanziierung "std::pair<size_t,size_t>::pair<__int64,unsigned int,0>(std::pair<__int64,unsigned int> &&) noexcept" der Funktions-Vorlage.
              C:\Users\thbeu\source\repos\cpp-httplib\build2\out\httplib.cc(3292,3):
              Ersten Verweis auf "std::pair<size_t,size_t>::pair" in "httplib::detail::get_range_offset_and_length" anzeigen
  
  httplib.vcxproj -> C:\Users\thbeu\source\repos\cpp-httplib\build2\Debug\cpp-httplib.lib
  Building Custom Rule C:/Users/thbeu/source/repos/cpp-httplib/CMakeLists.txt

I updated PR accordingly.

Comment thread httplib.h
@yhirose yhirose merged commit dffce89 into yhirose:master Aug 12, 2025
10 of 11 checks passed
@yhirose

yhirose commented Aug 12, 2025

Copy link
Copy Markdown
Owner

@thbeu thanks for your contribution!

@thbeu thbeu deleted the fix-c1021 branch August 13, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSVC: Invalid preprocessor command 'warning'

2 participants