|
|
1.1 root 1: When compiling a C program for PM, here are some points to note:
2: ----------------------------------------------------------------
3:
4: Segment setup
5: -------------
6:
7: There are 3 switches which specify segment setup (note that SS never changes):
8:
9: -Ad SS==DS.
10: SS and DS are loaded with the same value when the program
11: starts up and are assumed to be the same later on.
12: This is the default.
13:
14: -Aw SS!=DS, DS not reloaded on function entry.
15: SS is not assumed to equal DS, so if DS must contain the same value
16: as SS for some operation, DS is pushed, loaded, used and popped.
17:
18: -Au SS!=DS, DS reloaded on function entry, for all functions.
19: At the beginning of each function, DS is pushed
20: then loaded with the module's data segment (usually DGROUP).
21: At the end of each function, DS is popped. Also, any other
22: time DS must be changed, it is pushed, loaded, used and popped.
23: The _loadds keyword has the same effect, but on a
24: function-by-function basis.
25:
26: If you have a thread whose stack lies outside the default data segment
27: (eg. obtained by a call to DosAllocSeg, or if you compile large-model and
28: use malloc()), you must specify SS!=DS. Multi-threaded apps nearly always
29: have SS!=DS.
30:
31: Any routine which is called by code which uses a different data segment
32: (different value in DS) must use the _loadds keyword. Your program will
33: execute correctly if you use the -Au switch, but this switch generates DS
34: save, load and restore code for all functions, even ones which use the same
35: data segment. Generally, only window procedures or dll entry points need
36: this code.
37:
38: Summary:
39: If your program has multiple threads
40: Use the -Aw switch
41: Else
42: Use the -Ad switch
43:
44: Use the _loadds keyword when declaring window procedures and dll entry points.
45:
46:
47:
48: Window procedures
49: -----------------
50:
51: The preferred method of typing window procedures is to use the
52: CALLBACK keyword, defined in os2def.h:
53:
54: #define CALLBACK pascal far _loadds
55:
56: Note that window procedures need not be exported in PM (unlike Windows).
57:
58: The -Gw switch should not be used for PM application programs, since it
59: causes unnecessary code to be emitted. It will not cause incorrect
60: execution, but it is wasteful.
61:
62:
63:
64: C switches used in the samples
65: ------------------------------
66:
67: -Zi causes symbolic information used by CodeView to be generated
68:
69: -Zp packs structure members
70:
71: -Gs turns off stack checking. Useful if SS!=DS and C runtime libraries
72: are used.
73:
74: -G2 causes 286 instructions to be generated
75:
76: -Gc makes the Pascal calling convention the default
77:
78: -Od disables optimization. Useful when running CodeView.
79:
80: -NT sets the name of the text (code) segment
81:
82: -c compiles without linking
83:
84: -u removes definitions of all predefined identifiers
85:
86: -J changes the default type for char from signed to unsigned
87:
88: -W3 sets the compiler output warning level to its most sensitive
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.