DOCERR: C/C++ Windows Entry/Exit Code Switches (/GA /Gw /GW /Gq)

Last reviewed: July 17, 1997
Article ID: Q85503
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbdocerr

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C/C++ for MS-DOS, versions 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SUMMARY

There is a documentation error relating to the use of Windows entry/exit code optimization switches for Microsoft C/C++ versions 7.0 and 8.0. The article below corrects this and provides additional information about the use of the following switches:

   /GA /GD /GEf /Gw /GW /Gq

MORE INFORMATION

With Microsoft C/C++ versions 7.0 and 8.0, the documentation for the /Gw and /GW switches is incorrect in both the online help and the "Microsoft C/C++ Environment and Tools" manual on page 522 and the "Command Line User's Guide" manual starting on page 143. The section on /Gw and /GW incorrectly states that /Gw works only on functions explicitly marked as __export, while /GW works on those not marked as __export. In fact, neither switch is affected by the presence or absence of __export. Both switches only affect __far functions and ignore __near functions.

The /GA and /GD functions do require that functions be explicitly marked as __export if the switch is to affect them.

As stated in the documentation, /Gw, /GW, and /Gq should be used only for programs that must run in real mode Windows. Because real mode is not available under Windows 3.1, most programs should be built using the /GA switch (/GD for DLLs).

Note: /Gq is for use only when absolute compatibility is needed with the Microsoft C version 6.0 compiler /GW switch. The code generated is slightly less efficient than that generated by the C 7.0 /GW switch.

If you are using the /GA or /GD switch, and your code does not explicitly have the __export keyword for the callback functions, you may use the /GEf switch to cause all far functions (coded as __far) to be treated as exports (as though __export had been specified). If __export is explicitly coded, these functions do not need to be declared in the EXPORTS section of the definition file. It is recommended that __export be explicitly coded when new code is written.

The /GEf switch causes all functions to be treated as __export if used under medium or large memory model. In this case, the only way to control exporting is to explicitly code __export and not use /GEf.


Additional reference words: 1.00 1.50 7.00 8.00 8.00c _export _far entry
exit
KBCategory: kbtool kbdocerr
KBSubcategory: CLIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.