janstarke / rexgen

API Documentation
https://github.com/janstarke/rexgen/blob/master/doc/api.md
GNU General Public License v2.0
52 stars 21 forks source link

Cygwin build problems #27

Closed jfoug closed 8 years ago

jfoug commented 8 years ago

Under cygwin (64 bit but likely affects 32 bit also), I had to make these edits, or I end up with fileno not defined.

~/rexgen $ git diff
diff --git a/src/librexgen/CMakeLists.txt b/src/librexgen/CMakeLists.txt
index b205b49..5956fa6 100644
--- a/src/librexgen/CMakeLists.txt
+++ b/src/librexgen/CMakeLists.txt
@@ -21,7 +21,7 @@ include_directories(${ICU_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
 IF(MSVC)
   ADD_DEFINITIONS("-DUNICODE -D_UNICODE")
 ELSE()
-  ADD_DEFINITIONS("-std=c++11 -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Winline")
+  ADD_DEFINITIONS("-std=gnu++11 -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Winline")
 ENDIF(MSVC)

 FLEX_TARGET(regexscanner parser/regex_lexer.l ${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp COMPILE_FLAGS "")
diff --git a/src/librexgen/lua/CMakeLists.txt b/src/librexgen/lua/CMakeLists.txt
index 3db8404..8cc02ca 100644
--- a/src/librexgen/lua/CMakeLists.txt
+++ b/src/librexgen/lua/CMakeLists.txt
@@ -15,7 +15,7 @@ set(LUA_TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/lua")
 IF(MSVC)
   ADD_DEFINITIONS("-DUNICODE -D_UNICODE")
 ELSE()
-  ADD_DEFINITIONS("-std=c++11 -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Winline")
+  ADD_DEFINITIONS("-std=gnu++11 -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Winline")
 ENDIF(MSVC)

 set(lua-sources librexgen_lua.cpp)
jfoug commented 8 years ago

Here is another patch, I had to apply for cygwin-32 bit build (it was lacking ffsll() ) NOTE, I think ffsll should be there, I simply did not know the right compiler switch to get it working.

So instead I used the non-inline stuff, and found other problems.

$ git diff librexgen/common/ntz*
diff --git a/src/librexgen/common/ntz.cpp b/src/librexgen/common/ntz.cpp
index 43c2b64..2427d3a 100644
--- a/src/librexgen/common/ntz.cpp
+++ b/src/librexgen/common/ntz.cpp
@@ -47,7 +47,7 @@ int ntz11(unsigned int n) {

 #if ! defined(__USE_INLINE_NTZ__)
 #if __x86_64__
-unsigned int ntz(long long unsigned int x) {
+unsigned int ntz(uint64_t x) {
   const unsigned int lower_part =  (const unsigned int) (x & 0x00000000ffffffff);
   /* no need to AND-out the 32 right-most here,
    * since they are shifted out */
@@ -61,7 +61,7 @@ unsigned int ntz(long long unsigned int x) {
 }
 #else

-unsigned int ntz(long unsigned int x) {
+unsigned int ntz(uint32_t x) {
   return ntz11(x);
 }
 #endif /* __x86_64__ */
diff --git a/src/librexgen/common/ntz.h b/src/librexgen/common/ntz.h
index 96bbbc2..39065c8 100644
--- a/src/librexgen/common/ntz.h
+++ b/src/librexgen/common/ntz.h
@@ -25,7 +25,9 @@

 int ntz11(unsigned int n);

+#if ! (!__x64_64__ && __CYGWIN__)
 #define __USE_INLINE_NTZ__
+#endif

 #ifdef __USE_INLINE_NTZ__
 #if __x86_64__