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

Fix missing definition of UT_INT64 for APPLE #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dakcarto
Copy link

Otherwise, the following, when compiling on Mac OS X 10.11 with clang:

#include "fyba.h"
int main() {
  SK_EntPnt_FYBA char *LC_InqVer(void);
  return 0;
}

errors with...

/usr/local/Cellar/fyba/4.1.1/include/fyba/fyba.h:760:4: error: unknown type name 'UT_INT64'
   UT_INT64 n64AktPos;        // Aktuell posisjon for sekv. skriv / les
   ^
/usr/local/Cellar/fyba/4.1.1/include/fyba/fyba.h:761:2: error: unknown type name 'UT_INT64'
        UT_INT64 n64NesteLedigRbPos; // Neste ledige posisjon i buffer-filen
        ^
/usr/local/Cellar/fyba/4.1.1/include/fyba/fyba.h:804:4: error: unknown type name 'UT_INT64'
   UT_INT64    n64FilPosRb; // Aktuell posisjon i buffer-filen 
   ^
/usr/local/Cellar/fyba/4.1.1/include/fyba/fyba.h:1091:53: error: unknown type name 'UT_INT64'
SK_EntPnt_FYBA short HO_TestSOSI(const char *pszFil,UT_INT64 *sluttpos);

@dakcarto
Copy link
Author

Hi, any updates here. Thanks!

@petterreinholdtsen
Copy link

Note, I am not involved in this project, but noticed its lack of updates were mentioned on the Norwegian OpenStreetmap mailing list and decided to have a look at its state.

Looking at the patch, I suspect it is using a bad approach. Looking at https://en.wikipedia.org/wiki/C_data_types#stdint.h, it is clear that the (u)intX_t types are a part of standard C99, so no need to use apple specific ifdefs. It is similarly not sensible to only include the standard headers on Linux. I changed it to depend on the autoconf detected defines instead. Last, there is no use to have #ifdef WIN32 inside a block with #ifndef WIN32. I suggest this patch instead:

index abd515e..a0c8d77 100644
--- a/src/UT/fyut.h
+++ b/src/UT/fyut.h
@@ -57,11 +57,14 @@
 
 #else
           /* For UNIX */
-#  ifdef LINUX /* specifically the LINUX */
+/* Use C99 standard headers and types if they exist */
+#  ifdef HAVE_STDINT_H
 #    include <stdint.h>
+#  endif
+#  ifdef HAVE_INTTYPES_H
 #    include <inttypes.h>
-#    define UT_INT64 int64_t 
 #  endif
+#  define UT_INT64 int64_t 
 
 #   define UT_SNPRINTF snprintf
 #   define UT_FPRINTF fprintf
@@ -79,11 +82,7 @@
 #  include <limits.h>
 #  include <sys/types.h>
 
-#  ifdef WIN32
-#    include <io.h>
-#  else
-#    include <unistd.h>
-#  endif
+#  include <unistd.h>
 
 #  define _TRUNCATE 0
 #  define _fseeki64 fseek

Can you confirm it also work on MacOSX? I can only test on Linux, but expect it to work on any unix like os with C99. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants