C/C++ Compiler (cl.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.
Fastcall Calling Convention (/Gr)
                                             Up Contents Index Back
─────C/C++ Compiler─────────────────────────────────────────────────────────
 
     Usually, your program passes parameters to functions on the stack.
     The /Gr option causes your program to pass parameters in registers
     instead. Normally, this calling convention decreases execution
     time, but it gives no advantage if you compile with the Fast
     Compile (/f) option. Therefore, use the /Gr option only for final
     compilations that require the full optimizing capabilities of
     Microsoft C/C++.
 
     Passing parameters in registers is not appropriate for all
     functions. The /Gr option enables register passing for all
     eligible functions, and the __fastcall keyword enables it on a
     function-by-function basis. You cannot use the __fastcall keyword
     with the __pascal, __fortran, or __cdecl keywords.
 
     Because the 80x86 processor has a limited number of registers,
     only the first three parameters are passed in registers; the
     remaining parameters are passed using the FORTRAN/Pascal calling
     convention (see the /Gc option).
 
     NOTES:
 
        ■ The varargs and stdargs macros are incompatible with the
          Fastcall convention.
 
        ■ You can cause individual functions to observe the Fastcall
          conventions by declaring them with the __fastcall keyword.
 
        ■ The Fastcall calling convention requires that you provide
          function prototypes for external functions. Until you provide
          these prototypes, consider compiling without the /Gr option.
          See: Generate Function Prototypes (/Zg)
 
        ■ The Fastcall calling convention is not supported by p-code.
 
        ■ Be careful when using the register calling convention for any
          function written in inline assembly language. Your use of
          registers in assembly language could conflict with the
          compiler's use of registers for storing parameters.
 
     See also: C Calling Convention
               Pascal Calling Convention
                                    -♦-