s-yata / marisa-trie

MARISA: Matching Algorithm with Recursively Implemented StorAge
Other
511 stars 89 forks source link

Fix detection of MARISA_WORD_SIZE #58

Open ncopa opened 6 months ago

ncopa commented 6 months ago

Detect the MARISA_WORD_SIZE independent of architecture.

Fixes: https://github.com/s-yata/marisa-trie/issues/40 Fixes: https://github.com/s-yata/marisa-trie/issues/57 Fixes: https://github.com/s-yata/marisa-trie/pull/44 Fixes: https://github.com/s-yata/marisa-trie/pull/46 Fixes: https://github.com/s-yata/marisa-trie/pull/56

ncopa commented 6 months ago

Tested on Alpine Linux on:

https://gitlab.alpinelinux.org/alpine/aports/-/jobs/1359213

ncopa commented 6 months ago

I updated the commit to use UINTPTR_MAX.

It seems that Visual C++ 2010 and newer at least provides stdint.h. https://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio

Maybe we should do something like:

diff --git a/include/marisa/base.h b/include/marisa/base.h
index bddce4a..68e774b 100644
--- a/include/marisa/base.h
+++ b/include/marisa/base.h
@@ -2,7 +2,7 @@
 #define MARISA_BASE_H_

 // Old Visual C++ does not provide stdint.h.
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) || (_MSC_VER >= 1600)
  #include <stdint.h>
 #endif  // _MSC_VER