|
Compiling Compiling Code C Implementation C++ Implementation Language Extensions Mixing Languages Assembly Language Inline Assembler Optimizing Code Numerics Programming Regular Expressions Acrtused Pragmas Precompiled Headers Predefined Macros Warning Messages Error Messages Runtime Messages Linking Optlink Switches Module Definition Files Operation and Design Error Messages Win32 Programming Win32 Programming DOS and Win16 Programming Memory Models 16 Bit Pointer Types and Type Modifiers Handle Pointers DOS DOS 32 (DOSX) Win16 Win16 DLLs Win16 Prolog/Epilog C/C++ Extensions Contract Programming __debug statement __debug declaration Dynamic Profiling Embedding C in HTML Tools BCC CHMOD CL COFF2OMF COFFIMPLIB DMC DIFF DIFFDIR DUMP DUMPOBJ DUMPEXE EXE2BIN FLPYIMG GREP HC IMPLIB LIB LIBUNRES MAKE MAKEDEP ME OBJ2ASM PATCHOBJ RC RCC SC SHELL SMAKE TOUCH UNMANGLE WHEREIS Porting to DMC++ Switching to DMC++ from Microsoft from Borland Porting Guide |
Windows Prolog/Epilog Code GenerationFrom the IDDE, use the Windows Prolog/ Epilog subpage on the Build page of the IDDE's Project Settings dialog box.32 Bit Windows Prolog/Epilog Code Generation-WA Win32 EXE -WD Win32 DLL no -W switch Win32 console EXE app 16 Bit Windows Prolog/Epilog Code Generation
-W{0123ADabdefmrsuvwx-+}
-W Same as -W1 if no modifier switches
-W- Not a windows compile (default)
-W1 Real mode Windows app/DLL
-W2 Real mode Windows app/DLL with exported and
callback functions marked with __export
-W3 Real mode Windows app with smart callbacks
-WA Protected mode Windows EXE, with callback functions
all marked as __export.
-WD Protected mode Windows DLL, with callback and exported
functions all marked as __export.
Modifiers:
a Reload DS from DS for far functions
b Assume DS != DGROUP
d Reload DS from DGROUP for far functions
e Generate EXPDEF records in .OBJ file for __export functions
f Mark all far functions as __export
m Generate INC BP / DEC BP to mark far stack frames
r Generate reload of DS only if __export or __loadds functions
s Reload DS from SS for far functions (smart callbacks)
t Use fixups instead of CS. This is needed for real mode,
where selector values can change as code moves around.
u Reload DS from DGROUP for near and far functions
(same as -mu) (same as marking all functions as __loadds)
v Save/restore caller's DS in far functions
w Assume SS != DS (same as -mw)
x Program will be run under Windows
- Turn off subsequent modifiers
+ Turn on subsequent modifiers
Modifers a,d,s,v are mutually exclusive.
Equivalents:
-W1 -Wtxema -D_WINDOWS
-W2 -Wtxemar -D_WINDOWS
-W3 -Wtxems -D_WINDOWS
-WA -Wtxrs -D_WINDOWS
-WD -Wtxerdw -D_WINDOWS -D_WINDLL
-WD-r -Wtxedw -D_WINDOWS -D_WINDLL
We Recommend:
Don't Do This:
Microsoft C6 switch compatibility for Windows compiling:MSC SC/C++-Gw -W Full Windows prolog/epilog for far functions -GW -W2 Reduced prolog/epilog, Note 1 -Au -mwu assume SS != DS and load DS on each function -Aw -mw assume SS != DS Note 1: SC/C++ will still generate the full prolog/epilog for __far __export functions, MSC6 will not. </pre> <h3>Microsoft C7/VC switch compatibility for Windows compiling:</h3> <pre> MSC SC/C++-Gw -W Full Windows prolog/epilog for far functions -Au -mwu assume SS != DS and load DS on each function -Aw -mw assume SS != DS -GA -WA optimized protected mode Windows apps -GD -WD optimized protected mode Windows DLLs -GEa -Wa load DS from AX -GEd -Wd load DS from DGROUP -GEe -We emit EXPDEF records for all exported functions -GEf -W-r create prolog/epilog code for all far functions -GEm -Wm add inc BP / dec BP to prolog / epilog of far functions -GEr -W2v real mode, reduced prolog for non-exported functions -GEs -Ws load DS from SS -Gq -Wtxme compatibility with MSC6 -GW -GW -Wtxmev -D_WINDOWS reduced prolog for real mode Windows functions Special FeatureThe -Wb switch (assume DS != DGROUP) causes the compiler to issue a warning whenever a segment fixup is done to DGROUP. If your program is using an alternate data segment, this could mean that a DGROUP fixup is a program bug.A DGROUP fixup can be triggered (in large data model) by things like: static int x; static int *px = &x; /* DGROUP fixup generated */ static char *p = "abc"; /* DGROUP fixup generated */To get rid of the fixup, the pointers can be made near: static int __near *px = (int __near *)&x; static char __near *p = "abc";these will generate DGROUP relative fixups, not DGROUP segment fixups. Alternatively, the pointers can be initialized at runtime (the compiler generates code that uses DS to initialize segment values). Eliminating DGROUP segment fixups is useful for:
Note that -Wb will issue errors if you are using __loadds (because DS is reloaded from DGROUP) or if you are using -Wd (load DS from DGROUP Windows prologs). -W tells the compiler to ignore case when linking to make the programs more compatible with existing Windows programs (many of which are linked that way). When developing new programs, do not ignore case, since C and C++ are case-sensitive languages. Ignoring case can cause bugs that are difficult to trace. To compile a Windows program without ignoring case, use the options -W -L/noi sc -W -L/noi winprog.c References For 16 Bit Windows Prolog/EpilogsChapter 21"Programmer's Reference, Volume 1" Microsoft Windows SDK 3.1 Chapters 7 and 19 "Programming Windows 3.1, Third Edition" Charles Petzold Microsoft Press ISBN 1-55615-395-3 |