# Module for Large File Size system support detection?

**URL:** https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830
**Category:** Usage
**Created:** [March 20, 2020, 8:29pm UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830 "2020-03-20T20:29:40Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)
#### Post date: [March 20, 2020, 8:29pm UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/1 "2020-03-20T20:29:40Z")

</div>

Hi! We’re looking for a good C/C++/CMake solution for sorting out what the correct/best set of functions and file types is for off\_t/off64\_t/\_off64\_t and friends. (fseek,fstat,ftell, and their myriad 32/64/platform-specific variations across platforms, not to mention needed defines such as \_FILE\_OFFSET\_BITS?)

We’re looking for a configure-time set of tests that will let us define a set of wrappers for our code that just work and provide reliable access to large files under as many circumstances as possible - does anybody know of a good pre-packaged solution to this?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 20, 2020, 9:08pm UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/2 "2020-03-20T21:08:43Z")

</div>

These are still necessary today (I thought everyone just defined `_FILE_OFFSET_BITS=64` and called it a day)? I don’t know of a good pre-packaged CMake solution, but whatever autotools does would seem like a good starting point to me.

---

<div class="post-metadata">

### Author: ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)
#### Post date: [March 21, 2020, 12:20am UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/3 "2020-03-21T00:20:41Z")

</div>

One of the complications is Windows specific types (\_off64\_t for example). Does `\_FILE\_OFFSET\_BITS=64 work for the Windows API?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 21, 2020, 12:51am UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/4 "2020-03-21T00:51:49Z")

</div>

Eh, just check for `_WIN32` and use the types specified [in their docs](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=vs-2019). Things like `time64_t` are still being worked out, but `stat64_t` was migrated from ages ago on pretty much any relevant platform. Assume it is 64-bit where you can and special case the oddballs with a header using preprocessor magic. It’s a lot simpler than doing configure-time detection of feature macros. Basically, the time it takes you to figure out the stuff based on things like ` __linux__ ` once is going to be _much_ smaller than writing code to make everyone do it at configure time every time they make a new build tree.

---

<div class="post-metadata">

### Author: ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)
#### Post date: [March 21, 2020, 1:17am UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/5 "2020-03-21T01:17:52Z")

</div>

Do you happen to know if anyone’s already rolled a header with those definitions? We can tackle it if need be, but I’d hate to reinvent the wheel needlessly…

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 21, 2020, 1:23am UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/6 "2020-03-21T01:23:04Z")

</div>

I don’t know off-hand, sorry. I recommend searching [Debian Code Search](https://codesearch.debian.net/) and GitHub to see where `_FILE_OFFSET_BITS` and friends are being handled.

---

<div class="post-metadata">

### Author: ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)
#### Post date: [March 21, 2020, 1:28am UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/7 "2020-03-21T01:28:43Z")

</div>

Will do, thanks!

---

<div class="post-metadata">

### Author: ![anon74639460](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@anon74639460](https://discourse.cmake.org/u/anon74639460)
#### Post date: [January 1, 2026, 9:10pm UTC](https://discourse.cmake.org/t/module-for-large-file-size-system-support-detection/830/8 "2026-01-01T21:10:14Z")

</div>

Sorry to cryo-post on this thread, but, if anyone is still looking for this, CopperSpice, an Open-Source project using CMake has TestLargeFiles.cmake and Test64BitFiles.cmake in their repos.

> **[copperspice/cmake/modules at master · copperspice/copperspice](https://github.com/copperspice/copperspice/tree/master/cmake/modules)**
>
> Set of cross platform C++ libraries (Core, Gui, Network, Multimedia, SQL, Vulkan, etc) - copperspice/copperspice

I’m told you can still find 4-bit CPUs in remote controls. Not like you need a lot of horsepower for a simple one.
