@@ -92,23 +92,24 @@ to each definition in &cv-link-CPPDEFINES;.
92
92
<summary >
93
93
<para >
94
94
A platform independent specification of C preprocessor macro definitions.
95
- The definitions will be added to command lines
95
+ The definitions are added to command lines
96
96
through the automatically-generated
97
- &cv-link-_CPPDEFFLAGS; &consvar; (see above) ,
97
+ &cv-link-_CPPDEFFLAGS; &consvar; ,
98
98
which is constructed according to
99
- the type of value of &cv-CPPDEFINES; :
99
+ the contents of &cv-CPPDEFINES; :
100
100
</para >
101
101
102
102
<para >
103
103
If &cv-CPPDEFINES; is a string,
104
104
the values of the
105
105
&cv-link-CPPDEFPREFIX; and &cv-link-CPPDEFSUFFIX; &consvars;
106
- will be respectively prepended and appended to
107
- each definition in &cv-CPPDEFINES; .
106
+ are respectively prepended and appended to
107
+ each definition in &cv-CPPDEFINES; ,
108
+ split on whitespace.
108
109
</para >
109
110
110
111
<example_commands >
111
- # Will add -Dxyz to POSIX compiler command lines,
112
+ # Adds -Dxyz to POSIX compiler command lines,
112
113
# and /Dxyz to Microsoft Visual C++ command lines.
113
114
env = Environment(CPPDEFINES='xyz')
114
115
</example_commands >
@@ -117,15 +118,19 @@ env = Environment(CPPDEFINES='xyz')
117
118
If &cv-CPPDEFINES; is a list,
118
119
the values of the
119
120
&cv-CPPDEFPREFIX; and &cv-CPPDEFSUFFIX; &consvars;
120
- will be respectively prepended and appended to
121
+ are respectively prepended and appended to
121
122
each element in the list.
122
123
If any element is a list or tuple,
123
- then the first item is the name being
124
- defined and the second item is its value:
124
+ then the first item is the macro name
125
+ and the second item is the definition.
126
+ If the definition is not omitted,
127
+ these are combined into a
128
+ <literal >name=definition</literal > item
129
+ before the preending/appending.
125
130
</para >
126
131
127
132
<example_commands >
128
- # Will add -DB=2 -DA to POSIX compiler command lines,
133
+ # Adds -DB=2 -DA to POSIX compiler command lines,
129
134
# and /DB=2 /DA to Microsoft Visual C++ command lines.
130
135
env = Environment(CPPDEFINES=[('B', 2), 'A'])
131
136
</example_commands >
@@ -134,48 +139,43 @@ env = Environment(CPPDEFINES=[('B', 2), 'A'])
134
139
If &cv-CPPDEFINES; is a dictionary,
135
140
the values of the
136
141
&cv-CPPDEFPREFIX; and &cv-CPPDEFSUFFIX; &consvars;
137
- will be respectively prepended and appended to
138
- each item from the dictionary.
139
- The key of each dictionary item
140
- is a name being defined
141
- to the dictionary item's corresponding value;
142
- if the value is
143
- <literal >None</literal >,
144
- then the name is defined without an explicit value.
145
- Note that to ensure build order will be stable,
142
+ are respectively prepended and appended to
143
+ each key from the dictionary.
144
+ If the value for a key is not <literal >None</literal >,
145
+ then the key is the macro name and the value
146
+ is the definition and these are combined into a
147
+ <literal >name=definition</literal > item
148
+ before the prepending/appending.
149
+ Note that to ensure a stable build order,
146
150
&SCons; sorts the flags generated from the dictionary,
147
151
since a changed command line triggers a rebuild
148
152
(older &Python; interpreters did
149
- not guarantee to preserve dictionary keys in insert order),
153
+ not guarantee to preserve dictionary keys in insert order).
150
154
This precaution may be removed in a future version.
151
155
</para >
152
156
153
157
<example_commands >
154
- # Will add -DA -DB=2 to POSIX compiler command lines,
155
- # and /DA /DB=2 to Microsoft Visual C++ command lines.
158
+ # Adds -DA -DB=2 to POSIX compiler command lines,
159
+ # or /DA /DB=2 to Microsoft Visual C++ command lines.
156
160
env = Environment(CPPDEFINES={'B':2, 'A':None})
157
161
</example_commands >
158
162
159
163
<para >
160
164
Depending on how contents are added to &cv-CPPDEFINES; ,
161
165
it may end up as a compound type,
162
166
for example a list containing strings, tuples and/or dictionaries.
163
- &SCons; will still expand this correctly.
167
+ &SCons; expands this correctly.
164
168
</para >
165
169
166
170
<para >
167
- Note that if a value contains spaces (or other syntax that
168
- will be meaningful to the shell that calls the compiler)
169
- it needs to be quoted:
171
+ Note that &SCons; may call the compiler via a shell.
172
+ If a macro definition contains characters such as spaces that
173
+ have meaning to the shell, you may need to use the shell's
174
+ quoting syntax to avoid interpretation before the
175
+ preprocessor sees it. In particular, function-like macros
176
+ may be supported (see the documentation for the compiler in question),
177
+ but parentheses frequently have meaning to shells.
170
178
</para >
171
-
172
- <example_commands >
173
- # SPACED will just get the string 'spaced', arg will be a separate arg
174
- env = Environment(CPPDEFINES={'SPACED': 'spaced arg'})
175
- # SPACED will get the full value
176
- env = Environment(CPPDEFINES={'SPACED': '"spaced arg"'})
177
- </example_commands >
178
-
179
179
</summary >
180
180
</cvar >
181
181
0 commit comments