C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Functions Based in a Segment
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
     Form of <base>:
 
          __segname(<string literal>)
 
     A function declared as __based resides in the code segment named
     by <string literal>. You can use the __near or __far keywords
     with the __based keyword when declaring a function. In
     programs that use overlays, you can reduce swapping by using
     __based to group together functions that frequently call one
     another. You also can use __based to ensure that near functions
     reside in the same segment as the functions that call them.
 
     For example:
 
          // FILE 1 - compiled under large model
 
          void __based(__segname("MYSEG")) farfunc()  // far by default
          {
              nearfunc();
          }
 
          // FILE 2 - compiled under large model
 
          void __near __based(__segname("MYSEG") nearfunc()
          {
             // ...
          }
 
     If these two functions were not declared as based, this program
     would suffer a runtime error. Since both functions are
     based in the MYSEG segment, the program executes correctly.
                                    -♦-