[PR #32] [CLOSED] further fixes to allow compilation on MS Visual Studio 2010 #609

Open
opened 2026-01-29 20:46:25 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/32
Author: @anthrotype
Created: 2/26/2015
Status: Closed

Base: masterHead: win_build_8


📝 Commits (4)

  • d362ef7 [setup.py] use "-std=c++0x" only with GCC compiler (usupported on MSVC)
  • 3885510 [setup.py] enable C++ exception handling on MSVC compiler to fix warning C4530
  • cec8d4e [fast_log.h] define missing log2 function to allow building Python extension through MSVC 2010
  • a71f962 [literal_cost.cc] include fast_log.h to use defined log2 function

📊 Changes

3 files changed (+16 additions, -2 deletions)

View changed files

📝 enc/fast_log.h (+7 -0)
📝 enc/literal_cost.cc (+4 -0)
📝 python/setup.py (+5 -2)

📄 Description

Hello,

I don't like playing the Windows guy here, but there are still some unresolved issues with Microsoft's C++ compiler.

The recent patches by @szabadka ensured the Brotli encoder compiles successfully when using MS Visual Studio 2013.
However, the problem is that the latest Python for Windows (versions 3.3 and 3.4) are compiled with Visual Studio 2010.
Now, from what I understood, there's a requirement that Python extensions be linked to the same C runtime library which Python itself uses:

https://docs.python.org/3.4/extending/windows.html

If that's the case, then we must define a log2 (binary logarithm) function, which unfortunately is not present in math.h from Visual C++ 2010.
Here's my attempt, which seemingly doesn't break anything else, since I only redefine log2 if _MSC_VER <= 1600.

Through this patch, the Python extension can be built on Windows using the same compiler version used to build CPython itself.
Well, at least for Python 3.3 and 3.4... previous versions are still built with Visual Studio 2008, but I still had no luck with that.

Cheers,

C.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/32 **Author:** [@anthrotype](https://github.com/anthrotype) **Created:** 2/26/2015 **Status:** ❌ Closed **Base:** `master` ← **Head:** `win_build_8` --- ### 📝 Commits (4) - [`d362ef7`](https://github.com/google/brotli/commit/d362ef7b07a07eea4e9b3fc03d0265b2d11d9957) [setup.py] use "-std=c++0x" only with GCC compiler (usupported on MSVC) - [`3885510`](https://github.com/google/brotli/commit/38855105d79f95cbc8d6c0d252e4181f5c14c16c) [setup.py] enable C++ exception handling on MSVC compiler to fix warning C4530 - [`cec8d4e`](https://github.com/google/brotli/commit/cec8d4e735766ed6f71f721524d61df55afd097c) [fast_log.h] define missing log2 function to allow building Python extension through MSVC 2010 - [`a71f962`](https://github.com/google/brotli/commit/a71f962f749a5e5f31183d2d68b5c0cd074e7129) [literal_cost.cc] include fast_log.h to use defined log2 function ### 📊 Changes **3 files changed** (+16 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `enc/fast_log.h` (+7 -0) 📝 `enc/literal_cost.cc` (+4 -0) 📝 `python/setup.py` (+5 -2) </details> ### 📄 Description Hello, I don't like playing the Windows guy here, but there are still some unresolved issues with Microsoft's C++ compiler. The recent patches by @szabadka ensured the Brotli encoder compiles successfully when using MS Visual Studio 2013. However, the problem is that the latest Python for Windows (versions 3.3 and 3.4) are compiled with Visual Studio 2010. Now, from what I understood, there's a requirement that Python extensions be linked to the same C runtime library which Python itself uses: https://docs.python.org/3.4/extending/windows.html If that's the case, then we must define a `log2` (binary logarithm) function, which unfortunately is not present in `math.h` from Visual C++ 2010. Here's my attempt, which seemingly doesn't break anything else, since I only redefine log2 if `_MSC_VER <= 1600`. Through this patch, the Python extension can be built on Windows using the same compiler version used to build CPython itself. Well, at least for Python 3.3 and 3.4... previous versions are still built with Visual Studio 2008, but I still had no luck with that. Cheers, C. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:46:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#609