diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-05-12 12:33:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-05-12 12:33:40 +0000 |
commit | 312fc9f812932fddf159006784e61d4536751214 (patch) | |
tree | c7798a9c4183ece6ce7c02919c26b24364bd351d | |
parent | fe8256cd9784987c3055043a2aa7be4a8c0699c7 (diff) | |
download | libmicrohttpd-312fc9f812932fddf159006784e61d4536751214.tar.gz libmicrohttpd-312fc9f812932fddf159006784e61d4536751214.zip |
warn users about pitfall with 32-bit vs. 64-bit off_t
-rw-r--r-- | doc/microhttpd.texi | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/microhttpd.texi b/doc/microhttpd.texi index f46b7e87..e498b9b3 100644 --- a/doc/microhttpd.texi +++ b/doc/microhttpd.texi | |||
@@ -1403,6 +1403,28 @@ Return @mynull{} on error (i.e. invalid arguments, out of memory). | |||
1403 | @deftypefun {struct MHD_Response *} MHD_create_response_from_fd_at_offset (uint64_t size, int fd, off_t offset) | 1403 | @deftypefun {struct MHD_Response *} MHD_create_response_from_fd_at_offset (uint64_t size, int fd, off_t offset) |
1404 | Create a response object. The response object can be extended with | 1404 | Create a response object. The response object can be extended with |
1405 | header information and then it can be used any number of times. | 1405 | header information and then it can be used any number of times. |
1406 | Note that you need to be a bit careful about @code{off_t} when | ||
1407 | writing this code. Depending on your platform, @mhd{} is likely | ||
1408 | to have been compiled with support for 64-bit files. When you | ||
1409 | compile your own application, you must make sure that @code{off_t} | ||
1410 | is also a 64-bit value. If not, your compiler may pass a 32-bit | ||
1411 | value as @code{off_t}, which will result in 32-bits of garbage. | ||
1412 | |||
1413 | If you use the autotools, use the @code{AC_SYS_LARGEFILE} autoconf | ||
1414 | macro and make sure to include the generated @file{config.h} file | ||
1415 | before @file{microhttpd.h} to avoid problems. If you do not have a | ||
1416 | build system and only want to run on a GNU/Linux system, you could | ||
1417 | also use | ||
1418 | @verbatim | ||
1419 | #define _FILE_OFFSET_BITS 64 | ||
1420 | #include <sys/types.h> | ||
1421 | #include <sys/stat.h> | ||
1422 | #include <fcntl.h> | ||
1423 | #include <microhttpd.h> | ||
1424 | @end verbatim | ||
1425 | to ensure 64-bit @code{off_t}. Note that if your operating system | ||
1426 | does not support 64-bit files, @mhd{} will be compiled with a 32-bit | ||
1427 | @code{off_t} (in which case the above would be wrong...). | ||
1406 | 1428 | ||
1407 | @table @var | 1429 | @table @var |
1408 | @item size | 1430 | @item size |