]> git.xonotic.org Git - xonotic/gmqcc.git/blob - doc/gmqcc.1
8b86efee68cef42dc38b55dbd99a617817730f40
[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 -config= file
73 Use an ini file to read all the -O, -W and -f flag from. See the
74 CONFIG section about the file format.
75 .TP
76 .BI "-redirout=" file
77 Redirects standard output to a \fIfile\fR
78 .TP
79 .BI "-redirerr=" file
80 Redirects standard error to a \fIfile\fR
81 .TP
82 .BI "-std=" standard
83 Use the specified standard for parsing QC code. The following standards
84 are available:
85 .IR gmqcc , qcc , fteqcc
86 Selecting a standard also implies some -f options and behaves as if
87 those options have been written right after the -std option, meaning
88 if you changed them before the -std option, you're now overwriting
89 them.
90 .sp
91 .BR -std=gmqcc " includes:"
92 .in +4
93 -fadjust-vector-fields
94 .in
95 .BR -std=qcc " includes:"
96 .in +4
97 .nf
98 -fassign-function-types
99 -f\fIno-\fRadjust-vector-fields
100 .fi
101 .in
102 .BR -std=fteqcc " includes:"
103 .in +4
104 .nf
105 -fftepp
106 -ftranslatable-strings
107 -fassign-function-types
108 -Wternary-precedence
109 -f\fIno-\fRadjust-vector-fields
110 -f\fIno-\fRcorrect-ternary
111 .fi
112 .in
113 .SH Warnings
114 .TP
115 .B -Wunused-variable
116 Generate a warning about variables which are declared but never used.
117 This can be avoided by adding the \fInoref\fR keyword in front of the
118 variable declaration. Additionally a complete section of unreferenced
119 variables can be opened using \fI#pragma noref 1\fR, and closed via
120 \fI#pragma noref 0\fR.
121 .TP
122 .B -Wused-uninitialized
123 Generate a warning if it is possible that a variable can be used
124 without prior initialization. Note that this warning is not
125 necessarily reliable if the initialization happens only under certain
126 conditions. The other way is \fInot\fR possible: that the warning is
127 \fInot\fR generated when uninitialized use \fIis possible\fR.
128 .TP
129 .B -Wunknown-control-sequence
130 Generate an error when an unrecognized control sequence in a string is
131 used. Meaning: when there's a character after a backslash in a string
132 which has no known meaning.
133 .TP
134 .B -Wextensions
135 Warn when using special extensions which are not part of the selected
136 standard.
137 .TP
138 .B -Wfield-redeclared
139 Generally QC compilers ignore redeclaration of fields. Here you can
140 optionally enable a warning.
141 .TP
142 .B -Wmissing-return-values
143 Functions which aren't of type \fIvoid\fR will warn if it possible to
144 reach the end without returning an actual value.
145 .TP
146 .B -Wtoo-few-parameters
147 Warn about a function call with fewer parameters than the function
148 expects.
149 .TP
150 .B -Wlocal-shadows
151 Warn when a locally declared variable shadows variable.
152 .TP
153 .B -Wlocal-constants
154 Warn when the initialization of a local variable turns the variable
155 into a constant. This is default behaviour unless
156 \fI-finitialized-nonconstants\fR is used.
157 .TP
158 .B -Wvoid-variables
159 There are only 2 known global variables of type void: end_sys_globals
160 and end_sys_fields. Any other void-variable will warn.
161 .TP
162 .B -Wimplicit-function-pointer
163 A global function which is not declared with the \fIvar\fR keyword is
164 expected to have an implementing body, or be a builtin. If neither is
165 the case, it implicitly becomes a function pointer, and a warning is
166 generated.
167 .TP
168 .B -Wvariadic-function
169 Currently there's no way for an in QC implemented function to access
170 variadic parameters. If a function with variadic parameters has an
171 implementing body, a warning will be generated.
172 .TP
173 .B -Wframe-macros
174 Generate warnings about \fI$frame\fR commands, for instance about
175 duplicate frame definitions.
176 .TP
177 .B -Weffectless-statement
178 Warn about statements which have no effect. Any expression which does
179 not call a function or assigns a variable.
180 .TP
181 .B -Wend-sys-fields
182 The \fIend_sys_fields\fR variable is supposed to be a global variable
183 of type \fIvoid\fR. It is also recognized as a \fIfield\fR but this
184 will generate a warning.
185 .TP
186 .B -Wassign-function-types
187 Warn when assigning to a function pointer with an unmatching
188 signature. This usually happens in cases like assigning the null
189 function to an entity's .think function pointer.
190 .TP
191 .B -Wpreprocessor
192 Enable warnings coming from the preprocessor. Like duplicate macro
193 declarations.
194 .TP
195 .B -Wmultifile-if
196 Warn if there's a preprocessor \fI#if\fR spanning across several
197 files.
198 .TP
199 .B -Wdouble-declaration
200 Warn about multiple declarations of globals. This seems pretty common
201 in QC code so you probably do not want this unless you want to clean
202 up your code.
203 .TP
204 .B -Wconst-var
205 The combination of \fIconst\fR and \fIvar\fR is not illegal, however
206 different compilers may handle them differently. We were told, the
207 intention is to create a function-pointer which is not assignable.
208 This is exactly how we interpret it. However for this interpretation
209 the \fIvar\fR keyword is considered superfluous (and philosophically
210 wrong), so it is possible to generate a warning about this.
211 .TP
212 .B -Wmultibyte-character
213 Warn about multibyte character constants, they do not work right now.
214 .TP
215 .B -Wternary-precedence
216 Warn if a ternary expression which contains a comma operator is used
217 without enclosing parenthesis, since this is most likely not what you
218 actually want. We recommend the \fI-fcorrect-ternary\fR option.
219 .TP
220 .B -Wunknown-pragmas
221 Warn when encountering an unrecognized \fI#pragma\fR line.
222 .TP
223 .B -Wunreachable-code
224 Warn about unreachable code. That is: code after a return statement,
225 or code after a call to a function marked as 'noreturn'.
226 .TP
227 .B -Wdebug
228 Enable some warnings added in order to help debugging in the compiler.
229 You won't need this.
230 .SH Compile Flags
231 .TP
232 .B -foverlap-locals
233 Allow local variables to overlap with each other if they don't
234 interfer with each other. (Not implemented right now)
235 .TP
236 .B -fdarkplaces-string-table-bug
237 Add some additional characters to the string table in order to
238 compensate for a wrong boundcheck in some specific version of the
239 darkplaces engine.
240 .TP
241 .B -fadjust-vector-fields
242 When assigning to field pointers of type \fI.vector\fR the common
243 behaviour in compilers like \fIfteqcc\fR is to only assign the
244 x-component of the pointer. This means that you can use the vector as
245 such, but you cannot use its y and z components directly. This flag
246 fixes this behaviour. Before using it make sure your code does not
247 depend on the buggy behaviour.
248 .TP
249 .B -fftepp
250 Enable a partially fteqcc-compatible preprocessor. It supports all the
251 features used in the Xonotic codebase. If you need more, write a
252 ticket.
253 .TP
254 .B -frelaxed-switch
255 Allow switch cases to use non constant variables.
256 .TP
257 .B -fshort-logic
258 Perform early out in logical AND and OR expressions. The final result
259 will be either a 0 or a 1, see the next flag for more possibilities.
260 .TP
261 .B -fperl-logic
262 In many languages, logical expressions perform early out in a special
263 way: If the left operand of an AND yeilds true, or the one of an OR
264 yields false, the complete expression evaluates to the right side.
265 Thus \fItrue && 5\fI evaluates to 5 rather than 1.
266 .TP
267 .B -ftranslatable-strings
268 Enable the underscore intrinsic: Using \fI_("A string constant")\fR
269 will cause the string immediate to get a name with a "dotranslate_"
270 prefix. The darkplaces engine recognizes these and translates them in
271 a way similar to how gettext works.
272 .TP
273 .B -finitialized-nonconstants
274 Don't implicitly convert initialized variables to constants. With this
275 flag, the \fIconst\fR keyword is required to make a constant.
276 .TP
277 .B -fassign-function-types
278 If this flag is not set, (and it is set by default in the qcc and
279 fteqcc standards), assigning function pointers of mismatching
280 signatures will result in an error rather than a warning.
281 .TP
282 .B -flno
283 Produce a linenumber file along with the output .dat file.
284 .TP
285 .B -fcorrect-ternary
286 Use C's operator precedence for ternary expressions. Unless your code
287 depends on fteqcc-compatible behaviour, you'll want to use thi
288 soption.
289 .TP
290 .B -fsingle-vector-defs
291 Normally vectors generate 4 defs, once for the vector, and once for
292 its components with _x, _y, _z suffixes. This option
293 prevents components from being listed.
294 .SH CONFIG
295 The configuration file is similar to regular .ini files. Comments
296 start with hashtags or semicolons, sections are written in square
297 brackets and in each section there can be arbitrary many key-value
298 pairs.
299 .sp
300 There are 3 sections currently:
301 .IR flags ", " warnings ", and " optimizations .
302 They contain a list of boolean values of the form `VARNAME = true` or
303 `VARNAME = false`. The variable names are the same as for the
304 corresponding -W, -f or -O flag written with only capital letters and
305 dashes replaced by underscores.
306 .sp
307 Here's an example:
308 .in +4
309 .nf
310 # a GMQCC configuration file
311 [flags]
312     FTEPP = true
313     ADJUST_VECTOR_FIELDS = false
314     LNO = true
315
316 [warnings]
317     UNUSED_VARIABLE = false
318     USED_UNINITIALIZED = true
319
320 [optimizations]
321     PEEPHOLE = true
322     TAIL_RECURSION = true
323 .fi
324 .in
325 .SH BUGS
326 Please report bugs on <http://github.com/graphitemaster/gmqcc/issues>,
327 or see <http://graphitemaster.github.com/gmqcc> on how to contact us.
328 .SH SEE ALSO
329 .IR qcvm (1)
330 .SH AUTHOR
331 See <http://graphitemaster.github.com/gmqcc>.