git » libjio » commit f0c1e30

When linking an application that doesn't use Large File Support with the library (which does), several problems might arise from the data size differences.

author Alberto Bertogli
2004-09-19 04:32:38 UTC
committer Alberto Bertogli
2007-07-15 13:23:56 UTC
parent 280597679545ddf82a71b49a604fdcbd735e0e99

When linking an application that doesn't use Large File Support with the library (which does), several problems might arise from the data size differences.

When linking an application that doesn't use Large File Support with the
library (which does), several problems might arise from the data size
differences.

It's very important that everything uses the same interface. Since there's no
portable way to force the application we're linking with uses LFS, we just
give an error in case they don't. It might seem uglier, but it's a lot safer.

libjio.h +10 -0

diff --git a/libjio.h b/libjio.h
index 6fea3e5..0333a6e 100644
--- a/libjio.h
+++ b/libjio.h
@@ -12,6 +12,16 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <pthread.h>
+#include <unistd.h>
+
+/* Check if we're using Large File Support - otherwise refuse to build.
+ * Otherwise, we would allow applications not using LFS to link with the
+ * library (which uses LFS) and that's just begging for problems. There should
+ * be a portable way for the C library to do some of this for us, but until I
+ * find one, this is the best we can do */
+#if (!defined _FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS != 64)
+#error "You must compile your application with Large File Support"
+#endif
 
 #ifdef __cplusplus
 extern "C" {