]> git.xonotic.org Git - xonotic/gmqcc.git/blob - doc/gmqcc.1
Adding -f flags to 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 "-std=" standard
54 Use the specified standard for parsing QC code. The following standards
55 are available:
56 .IR gmqcc , qcc , fteqcc
57 .TP
58 .BI -W warning "\fR, " "" -Wno- warning
59 Enable or disable a warning.
60 .TP
61 .B -Wall
62 Enable all warnings. Overrides preceding -W parameters.
63 .TP
64 .B -Whelp
65 List all possible warn flags.
66 .TP
67 .BI -f flag "\fR, " "" -fno- flag
68 Enable or disable a specific compile flag. See the list of flags
69 below.
70 .TP
71 .B -fhelp
72 List all possible compile flags.
73 .TP
74 .B -nocolor
75 Disables colored output
76 .TP
77 .BI "-redirout=" file
78 Redirects standard output to a \fIfile\fR
79 .TP
80 .BI "-rediterr=" file
81 Redirects standard error to a \fIfile\fR
82 .SH Warnings
83 .TP
84 .B -Wunused-variable
85 Generate a warning about variables which are declared but never used.
86 This can be avoided by adding the \fInoref\fR keyword in front of the
87 variable declaration. Additionally a complete section of unreferenced
88 variables can be opened using \fI#pragma noref 1\fR, and closed via
89 \fI#pragma noref 0\fR.
90 .TP
91 .B -Wused-uninitialized
92 Generate a warning if it is possible that a variable can be used
93 without prior initialization. Note that this warning is not
94 necessarily reliable if the initialization happens only under certain
95 conditions. The other way is \fInot\fR possible: that the warning is
96 \fInot\fR generated when uninitialized use \fIis possible\fR.
97 .TP
98 .B -Wunknown-control-sequence
99 Generate an error when an unrecognized control sequence in a string is
100 used. Meaning: when there's a character after a backslash in a string
101 which has no known meaning.
102 .TP
103 .B -Wextensions
104 Warn when using special extensions which are not part of the selected
105 standard.
106 .TP
107 .B -Wfield-redeclared
108 Generally QC compilers ignore redeclaration of fields. Here you can
109 optionally enable a warning.
110 .TP
111 .B -Wmissing-return-values
112 Functions which aren't of type \fIvoid\fR will warn if it possible to
113 reach the end without returning an actual value.
114 .TP
115 .B -Wtoo-few-parameters
116 Warn about a function call with fewer parameters than the function
117 expects.
118 .TP
119 .B -Wlocal-shadows
120 Warn when a locally declared variable shadows variable.
121 .TP
122 .B -Wlocal-constants
123 Warn when the initialization of a local variable turns the variable
124 into a constant. This is default behaviour unless
125 \fI-finitialized-nonconstants\fR is used.
126 .TP
127 .B -Wvoid-variables
128 There are only 2 known global variables of type void: end_sys_globals
129 and end_sys_fields. Any other void-variable will warn.
130 .TP
131 .B -Wimplicit-function-pointer
132 A global function which is not declared with the \fIvar\fR keyword is
133 expected to have an implementing body, or be a builtin. If neither is
134 the case, it implicitly becomes a function pointer, and a warning is
135 generated.
136 .TP
137 .B -Wvariadic-function
138 Currently there's no way for an in QC implemented function to access
139 variadic parameters. If a function with variadic parameters has an
140 implementing body, a warning will be generated.
141 .TP
142 .B -Wframe-macros
143 Generate warnings about \fI$frame\fR commands, for instance about
144 duplicate frame definitions.
145 .TP
146 .B -Weffectless-statement
147 Warn about statements which have no effect. Any expression which does
148 not call a function or assigns a variable.
149 .TP
150 .B -Wend-sys-fields
151 The \fIend_sys_fields\fR variable is supposed to be a global variable
152 of type \fIvoid\fR. It is also recognized as a \fIfield\fR but this
153 will generate a warning.
154 .TP
155 .B -Wassign-function-types
156 Warn when assigning to a function pointer with an unmatching
157 signature. This usually happens in cases like assigning the null
158 function to an entity's .think function pointer.
159 .TP
160 .B -Wpreprocessor
161 Enable warnings coming from the preprocessor. Like duplicate macro
162 declarations.
163 .TP
164 .B -Wmultifile-if
165 Warn if there's a preprocessor \fI#if\fR spanning across several
166 files.
167 .TP
168 .B -Wdouble-declaration
169 Warn about multiple declarations of globals. This seems pretty common
170 in QC code so you probably do not want this unless you want to clean
171 up your code.
172 .TP
173 .B -Wconst-var
174 The combination of \fIconst\fR and \fIvar\fR is not illegal, however
175 different compilers may handle them differently. We were told, the
176 intention is to create a function-pointer which is not assignable.
177 This is exactly how we interpret it. However for this interpretation
178 the \fIvar\fR keyword is considered superfluous (and philosophically
179 wrong), so it is possible to generate a warning about this.
180 .TP
181 .B -Wmultibyte-character
182 Warn about multibyte character constants, they do not work right now.
183 .TP
184 .B -Wternary-precedence
185 Warn if a ternary expression which contains a comma operator is used
186 without enclosing parenthesis, since this is most likely not what you
187 actually want. We recommend the \fI-fcorrect-ternary\fR option.
188 .TP
189 .B -Wdebug
190 Enable some warnings added in order to help debugging in the compiler.
191 You won't need this.
192 .SH Compile Flags
193 .TP
194 .B -foverlap-locals
195 Allow local variables to overlap with each other if they don't
196 interfer with each other. (Not implemented right now)
197 .TP
198 .B -fdarkplaces-string-table-bug
199 Add some additional characters to the string table in order to
200 compensate for a wrong boundcheck in some specific version of the
201 darkplaces engine.
202 .TP
203 .B -fadjust-vector-fields
204 When assigning to field pointers of type \fI.vector\fR the common
205 behaviour in compilers like \fIfteqcc\fR is to only assign the
206 x-component of the pointer. This means that you can use the vector as
207 such, but you cannot use its y and z components directly. This flag
208 fixes this behaviour. Before using it make sure your code does not
209 depend on the buggy behaviour.
210 .TP
211 .B -fftepp
212 Enable a partially fteqcc-compatible preprocessor. It supports all the
213 features used in the Xonotic codebase. If you need more, write a
214 ticket.
215 .TP
216 .B -frelaxed-switch
217 Allow switch cases to use non constant variables.
218 .TP
219 .B -fshort-logic
220 Perform early out in logical AND and OR expressions. The final result
221 will be either a 0 or a 1, see the next flag for more possibilities.
222 .TP
223 .B -fperl-logic
224 In many languages, logical expressions perform early out in a special
225 way: If the left operand of an AND yeilds true, or the one of an OR
226 yields false, the complete expression evaluates to the right side.
227 Thus \fItrue && 5\fI evaluates to 5 rather than 1.
228 .TP
229 .B -ftranslatable-strings
230 Enable the underscore intrinsic: Using \fI_("A string constant")\fR
231 will cause the string immediate to get a name with a "dotranslate_"
232 prefix. The darkplaces engine recognizes these and translates them in
233 a way similar to how gettext works.
234 .TP
235 .B -finitialized-nonconstants
236 Don't implicitly convert initialized variables to constants. With this
237 flag, the \fIconst\fR keyword is required to make a constant.
238 .TP
239 .B -fassign-function-types
240 If this flag is not set, (and it is set by default in the qcc and
241 fteqcc standards), assigning function pointers of mismatching
242 signatures will result in an error rather than a warning.
243 .TP
244 .B -flno
245 Produce a linenumber file along with the output .dat file.
246 .TP
247 .B -fcorrect-ternary
248 Use C's operator precedence for ternary expressions. Unless your code
249 depends on fteqcc-compatible behaviour, you'll want to use thi
250 soption.