title: How can I portably turn on large file support?
body: <p>I am currently writing a C program that reads and writes files that might be over 2 GiB in size. On linux <strong>feature_test_macros</strong>(7) specifies:</p>
  
  <blockquote>
  <pre><code>   _LARGEFILE64_SOURCE
            Expose definitions for the alternative API specified by the LFS (Large File Summit) as a  "tran‐
            sitional  extension"  to  the  Single  UNIX  Specification.  (See ⟨http://opengroup.org/platform
            /lfs.html⟩) The alternative API consists of a set of new objects  (i.e.,  functions  and  types)
            whose names are suffixed with "64" (e.g., off64_t versus off_t, lseek64() versus lseek(), etc.).
            New programs should not employ this interface; instead _FILE_OFFSET_BITS=64 should be employed.
  
     _FILE_OFFSET_BITS
            Defining this macro with the value 64 automatically converts references to 32-bit functions  and
            data  types related to file I/O and file system operations into references to their 64-bit coun‐
            terparts.  This is useful for performing I/O on large files (&gt; 2 Gigabytes) on  32-bit  systems.
            (Defining  this macro permits correctly written programs to use large files with only a recompi‐
            lation being required.)  64-bit systems naturally permit file sizes greater  than  2  Gigabytes,
            and on those systems this macro has no effect.
  </code></pre>
  </blockquote>
  
  <p>Is this guaranteed to be portable?</p>
  
  <p>Solaris suggests in <strong>lfcompile</strong>(5):</p>
  
  <blockquote>
  <pre><code> Applications can be compiled in the large  file  compilation
   environment by using the following methods:
  
       o    Use the getconf(1) utility with one or more of  the
            arguments listed in the table below. This method is
            recommended for portable applications.
  
            ____________________________________________________________
           |     argument     |                 purpose                |
           |__________________|________________________________________|
           | LFS_CFLAGS       |  obtain compilation flags necessary  to|
           |                  |  enable   the  large  file  compilation|
           |                  |  environment                           |
           | LFS_LDFLAGS      |  obtain link editor options            |
           | LFS_LIBS         |  obtain link library names             |
           | LFS_LINTFLAGS    |  obtain lint options                   |
           |__________________|________________________________________|
  
       o    Set the compile-time flag _FILE_OFFSET_BITS  to  64
            before including any headers. Applications may com-
            bine objects produced in the large file compilation
            environment  with  objects  produced in the transi-
            tional compilation environment, but must be careful
            with  respect  to  interoperability  between  those
            objects. Applications  should  not  declare  global
            variables of types whose sizes change between  com-
            pilation environments.
  </code></pre>
  </blockquote>
  
  <p>Is this portable? On my linux machine, passing these keys to <strong>getconf</strong> will output nothing. (Which means the keys exist).</p>
  
  <p>Is there any portable approach?</p>