Skip to content
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

further fixes to allow compilation on MS Visual Studio 2010 #32

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions enc/fast_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ static const float kLog2Table[] = {
7.9943534368588578f
};

#if defined(_MSC_VER) && _MSC_VER <= 1600
// Calculates log2 of number (missing from MSC v.1600 required for Python bindings)
inline double log2( double n ) {
return log( n ) / log( 2. );
}
#endif

// Faster logarithm for small integers, with the property of log2(0) == 0.
static inline double FastLog2(int v) {
if (v < (int)(sizeof(kLog2Table) / sizeof(kLog2Table[0]))) {
Expand Down
4 changes: 4 additions & 0 deletions enc/literal_cost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#include "./literal_cost.h"

#if defined(_MSC_VER) && _MSC_VER <= 1600
#include "./fast_log.h"
#endif

#include <math.h>
#include <stdint.h>
#include <algorithm>
Expand Down
7 changes: 5 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ def build_extension(self, ext):

objects = []
for lang, sources in (("c", c_sources), ("c++", cxx_sources)):
if lang == "c++":
extra_args.append("-std=c++0x")
if lang == "c++":
if self.compiler.compiler_type in ["unix", "cygwin", "mingw32"]:
extra_args.append("-std=c++0x")
elif self.compiler.compiler_type == "msvc":
extra_args.append("/EHsc")

macros = ext.define_macros[:]
if platform.system() == "Darwin":
Expand Down