Pages

2011-11-09

_FILE_OFFSET_BITS

Be careful when using _FILE_OFFSET_BITS=64 to compile a program that calls a library or a library if any of the interfaces uses off_t. With _FILE_OFFSET_BITS=64 glibc will change the type of off_t to off64_t. You can either change the interface to always use off64_t, use a different function if _FILE_OFFSET_BITS=64 is used (like glibc does). Otherwise take care that both library and program have the same _FILE_OFFSET_BITS setting. Note that glibc is aware of the _FILE_OFFSET_BITS setting, there's no problem with it but there might be problems with other libraries.

@淘宝雕梁:nginx中定义了_FILE_OFFSET_BITS=64, 这个宏会导致off_t为8个字节(32位系统),而这个宏并没有通过gcc的编译参数传递进来,只是定义在ngx_linux_config.h的开头。于是如果编写模块,在模块的代码中必须把nginx的头文件包含在最上面,否则会导致在模块的代码中off_t的大小和在nginx中的大小不一致。

No comments:

Post a Comment