]> git.xonotic.org Git - xonotic/gmqcc.git/blob - doc/gmqcc.1
Add included -fs and -Ws to for each -std in the manpage
[xonotic/gmqcc.git] / doc / gmqcc.1
1 .\" Process with groff -man -Tascii file.3
2 .TH GMQCC 1 2012-07-12 "" "gmqcc Manual"
3 .SH NAME
4 gmqcc \- A Quake C compiler built from the NIH realm of sarcastic wit
5 .SH SYNOPSIS
6 .B gmqcc
7 [\fIOPTIONS\fR] [\fIfiles...\fR]
8 .SH DESCRIPTION
9 Traditionally, a QC compiler reads the file \fIprogs.src\fR which
10 in its first line contains the output filename, and the rest is a
11 list of QC source files that are to be compiled in order.
12 \fBgmqcc\fR optionally takes options to specify the output and
13 input files on the commandline, and also accepts assembly files.
14 .SH OPTIONS
15 \fBgmqcc\fR mostly tries to mimick gcc's commandline handling, though
16 there are also traditional long-options available.
17 .TP
18 .B "-h, --help"
19 Show a usage message and exit.
20 .TP
21 .B "-debug"
22 Turn on some compiler debugging mechanisms.
23 .TP
24 .B "-memchk"
25 Turn on compiler mem-check. (Shows allocations and checks for leaks.)
26 .TP
27 .BI "-o, --output=" filename
28 Specify the output filename. Defaults to progs.dat. This will overwrite
29 the output file listed in a \fIprogs.src\fR file in case such a file is used.
30 .TP
31 .BI "-O" number
32 Specify the optimization level
33 .RS
34 .IP 3
35 Highest optimization level
36 .IP 2
37 Default optimization level
38 .IP 1
39 Minimal optimization level
40 .IP 0
41 Disable optimization entierly
42 .RE
43 .TP
44 .BI "-O" name "\fR, " "" -Ono- name
45 Enable or disable a specific optimization. Note that these options
46 must be used after setting the optimization level, otherwise they'll
47 be overwritten.
48 .TP
49 .B -Ohelp
50 List all possible optimizations and the optimization level they're
51 activated at.
52 .TP
53 .BI -W warning "\fR, " "" -Wno- warning
54 Enable or disable a warning.
55 .TP
56 .B -Wall
57 Enable all warnings. Overrides preceding -W parameters.
58 .TP
59 .B -Whelp
60 List all possible warn flags.
61 .TP
62 .BI -f flag "\fR, " "" -fno- flag
63 Enable or disable a specific compile flag. See the list of flags
64 below.
65 .TP
66 .B -fhelp
67 List all possible compile flags.
68 .TP
69 .B -nocolor
70 Disables colored output
71 .TP
72 .BI "-redirout=" file
73 Redirects standard output to a \fIfile\fR
74 .TP
75 .BI "-redirerr=" file
76 Redirects standard error to a \fIfile\fR
77 .TP
78 .BI "-std=" standard
79 Use the specified standard for parsing QC code. The following standards
80 are available:
81 .IR gmqcc , qcc , fteqcc
82 Selecting a standard also implies some -f options and behaves as if
83 those options have been written right after the -std option, meaning
84 if you changed them before the -std option, you're now overwriting
85 them.
86 .sp
87 .BR -std=gmqcc " includes:"
88 .in +4
89 -fadjust-vector-fields
90 .in
91 .BR -std=qcc " includes:"
92 .in +4
93 .nf
94 -fassign-function-types
95 -f\fIno-\fRadjust-vector-fields
96 .fi
97 .in
98 .BR -std=fteqcc " includes:"
99 .in +4
100 .nf
101 -fftepp
102 -ftranslatable-strings
103 -fassign-function-types
104 -Wternary-precedence
105 -f\fIno-\fRadjust-vector-fields
106 -f\fIno-\fRcorrect-ternary
107 .fi
108 .in
109 .SH Warnings
110 .TP
111 .B -Wunused-variable
112 Generate a warning about variables which are declared but never used.
113 This can be avoided by adding the \fInoref\fR keyword in front of the
114 variable declaration. Additionally a complete section of unreferenced
115 variables can be opened using \fI#pragma noref 1\fR, and closed via
116 \fI#pragma noref 0\fR.
117 .TP
118 .B -Wused-uninitialized
119 Generate a warning if it is possible that a variable can be used
120 without prior initialization. Note that this warning is not
121 necessarily reliable if the initialization happens only under certain
122 conditions. The other way is \fInot\fR possible: that the warning is
123 \fInot\fR generated when uninitialized use \fIis possible\fR.
124 .TP
125 .B -Wunknown-control-sequence
126 Generate an error when an unrecognized control sequence in a string is
127 used. Meaning: when there's a character after a backslash in a string
128 which has no known meaning.
129 .TP
130 .B -Wextensions
131 Warn when using special extensions which are not part of the selected
132 standard.
133 .TP
134 .B -Wfield-redeclared
135 Generally QC compilers ignore redeclaration of fields. Here you can
136 optionally enable a warning.
137 .TP
138 .B -Wmissing-return-values
139 Functions which aren't of type \fIvoid\fR will warn if it possible to
140 reach the end without returning an actual value.
141 .TP
142 .B -Wtoo-few-parameters
143 Warn about a function call with fewer parameters than the function
144 expects.
145 .TP
146 .B -Wlocal-shadows
147 Warn when a locally declared variable shadows variable.
148 .TP
149 .B -Wlocal-constants
150 Warn when the initialization of a local variable turns the variable
151 into a constant. This is default behaviour unless
152 \fI-finitialized-nonconstants\fR is used.
153 .TP
154 .B -Wvoid-variables
155 There are only 2 known global variables of type void: end_sys_globals
156 and end_sys_fields. Any other void-variable will warn.
157 .TP
158 .B -Wimplicit-function-pointer
159 A global function which is not declared with the \fIvar\fR keyword is
160 expected to have an implementing body, or be a builtin. If neither is
161 the case, it implicitly becomes a function pointer, and a warning is
162 generated.
163 .TP
164 .B -Wvariadic-function
165 Currently there's no way for an in QC implemented function to access
166 variadic parameters. If a function with variadic parameters has an
167 implementing body, a warning will be generated.
168 .TP
169 .B -Wframe-macros
170 Generate warnings about \fI$frame\fR commands, for instance about
171 duplicate frame definitions.
172 .TP
173 .B -Weffectless-statement
174 Warn about statements which have no effect. Any expression which does
175 not call a function or assigns a variable.
176 .TP
177 .B -Wend-sys-fields
178 The \fIend_sys_fields\fR variable is supposed to be a global variable
179 of type \fIvoid\fR. It is also recognized as a \fIfield\fR but this
180 will generate a warning.
181 .TP
182 .B -Wassign-function-types
183 Warn when assigning to a function pointer with an unmatching
184 signature. This usually happens in cases like assigning the null
185 function to an entity's .think function pointer.
186 .TP
187 .B -Wpreprocessor
188 Enable warnings coming from the preprocessor. Like duplicate macro
189 declarations.
190 .TP
191 .B -Wmultifile-if
192 Warn if there's a preprocessor \fI#if\fR spanning across several
193 files.
194 .TP
195 .B -Wdouble-declaration
196 Warn about multiple declarations of globals. This seems pretty common
197 in QC code so you probably do not want this unless you want to clean
198 up your code.
199 .TP
200 .B -Wconst-var
201 The combination of \fIconst\fR and \fIvar\fR is not illegal, however
202 different compilers may handle them differently. We were told, the
203 intention is to create a function-pointer which is not assignable.
204 This is exactly how we interpret it. However for this interpretation
205 the \fIvar\fR keyword is considered superfluous (and philosophically
206 wrong), so it is possible to generate a warning about this.
207 .TP
208 .B -Wmultibyte-character
209 Warn about multibyte character constants, they do not work right now.
210 .TP
211 .B -Wternary-precedence
212 Warn if a ternary expression which contains a comma operator is used
213 without enclosing parenthesis, since this is most likely not what you
214 actually want. We recommend the \fI-fcorrect-ternary\fR option.
215 .TP
216 .B -Wunknown-pragmas
217 Warn when encountering an unrecognized \fI#pragma\fR line.
218 .TP
219 .B -Wdebug
220 Enable some warnings added in order to help debugging in the compiler.
221 You won't need this.
222 .SH Compile Flags
223 .TP
224 .B -foverlap-locals
225 Allow local variables to overlap with each other if they don't
226 interfer with each other. (Not implemented right now)
227 .TP
228 .B -fdarkplaces-string-table-bug
229 Add some additional characters to the string table in order to
230 compensate for a wrong boundcheck in some specific version of the
231 darkplaces engine.
232 .TP
233 .B -fadjust-vector-fields
234 When assigning to field pointers of type \fI.vector\fR the common
235 behaviour in compilers like \fIfteqcc\fR is to only assign the
236 x-component of the pointer. This means that you can use the vector as
237 such, but you cannot use its y and z components directly. This flag
238 fixes this behaviour. Before using it make sure your code does not
239 depend on the buggy behaviour.
240 .TP
241 .B -fftepp
242 Enable a partially fteqcc-compatible preprocessor. It supports all the
243 features used in the Xonotic codebase. If you need more, write a
244 ticket.
245 .TP
246 .B -frelaxed-switch
247 Allow switch cases to use non constant variables.
248 .TP
249 .B -fshort-logic
250 Perform early out in logical AND and OR expressions. The final result
251 will be either a 0 or a 1, see the next flag for more possibilities.
252 .TP
253 .B -fperl-logic
254 In many languages, logical expressions perform early out in a special
255 way: If the left operand of an AND yeilds true, or the one of an OR
256 yields false, the complete expression evaluates to the right side.
257 Thus \fItrue && 5\fI evaluates to 5 rather than 1.
258 .TP
259 .B -ftranslatable-strings
260 Enable the underscore intrinsic: Using \fI_("A string constant")\fR
261 will cause the string immediate to get a name with a "dotranslate_"
262 prefix. The darkplaces engine recognizes these and translates them in
263 a way similar to how gettext works.
264 .TP
265 .B -finitialized-nonconstants
266 Don't implicitly convert initialized variables to constants. With this
267 flag, the \fIconst\fR keyword is required to make a constant.
268 .TP
269 .B -fassign-function-types
270 If this flag is not set, (and it is set by default in the qcc and
271 fteqcc standards), assigning function pointers of mismatching
272 signatures will result in an error rather than a warning.
273 .TP
274 .B -flno
275 Produce a linenumber file along with the output .dat file.
276 .TP
277 .B -fcorrect-ternary
278 Use C's operator precedence for ternary expressions. Unless your code
279 depends on fteqcc-compatible behaviour, you'll want to use thi
280 soption.
281 .TP
282 .B -fsingle-vector-defs
283 Normally vectors generate 4 defs, once for the vector, and once for
284 its components with _x, _y, _z suffixes. This option
285 prevents components from being listed.