Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thbeu
Copy link
Contributor

@thbeu thbeu commented Aug 8, 2025

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
#pragma message( \
"cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler.")
#endif
#else
#if defined(_WIN32) && !defined(_WIN64)
#warning \
Copy link
Owner

@yhirose yhirose Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough to change only this line to #pragma message(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I only fixed the compiler error and did not touch the warning case on purpose.

@yhirose
Copy link
Owner

yhirose commented Aug 10, 2025

@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

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