Build failure on windows, no 'inline' keyword
ligo-segments
fails to build on windows using visual studio:
creating build\temp.win32-2.7\Release\src
C:\Users\appveyor\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc -IC:\Python27\include -IC:\Python27\PC /Tcsrc/segments.c /Fobuild\temp.win32-2.7\Release\src/segments.obj
segments.c
c:\users\appveyor\appdata\local\temp\1\pip-req-build-aienan\src\six.h(51) : error C2054: expected '(' to follow 'inline'
c:\users\appveyor\appdata\local\temp\1\pip-req-build-aienan\src\six.h(52) : error C2085: 'PyModule_Create' : not in formal parameter list
c:\users\appveyor\appdata\local\temp\1\pip-req-build-aienan\src\six.h(52) : error C2143: syntax error : missing ';' before '{'
c:\users\appveyor\appdata\local\temp\1\pip-req-build-aienan\src\six.h(64) : error C2054: expected '(' to follow 'inline'
c:\users\appveyor\appdata\local\temp\1\pip-req-build-aienan\src\six.h(65) : error C2085: 'PyModule_Create2' : not in formal parameter list
c:\users\appveyor\appdata\local\temp\1\pip-req-build-aienan\src\six.h(65) : error C2143: syntax error : missing ';' before '{'
src/segments.c(72) : warning C4013: 'PyModule_Create' undefined; assuming extern returning int
src/segments.c(72) : warning C4047: '=' : 'PyObject *' differs in levels of indirection from 'int'
error: command 'C:\\Users\\appveyor\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
The solution (I think) is to add something like this to segments.h
:
diff --git a/src/segments.h b/src/segments.h
index 2b2b1ad..0f3558e 100644
--- a/src/segments.h
+++ b/src/segments.h
@@ -36,6 +36,26 @@
#define MODULE_NAME "ligo.__segments"
+#ifdef _MSC_VER
+ #define inline __inline
+ #ifndef NAN
+ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
+ #define NAN (*(const double *) __nan)
+ #endif
+ #ifndef INFINITY
+ static const unsigned long __infinity[2] = {0x00000000, 0x7ff00000};
+ #define INFINITY (*(const double *) __infinity)
+ #endif
+#else
+ #ifndef INFINITY
+ #define INFINITY (1.0/0.0)
+ #endif
+ #ifndef NAN
+ #define NAN (INFINITY-INFINITY)
+ #endif
+#endif
+
+
/*
* ============================================================================
*
(and similarly to six.h
). @kipp.cannon, does that make sense to you?
Or, should we just forgo building the C extensions on windows and provide only the pure-python version?
Edited by Duncan Macleod