5 <meta http-equiv="X-UA-Compatible" content="chrome=1">
8 <link rel="stylesheet" href="stylesheets/styles.css">
9 <link rel="stylesheet" href="stylesheets/pygment_trac.css">
10 <script src="javascripts/scale.fix.js"></script>
11 <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
13 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
17 <a href="https://github.com/graphitemaster/gmqcc"><div class="fork"></div></a>
20 <h1 class="header">GMQCC</h1>
21 <p class="header">An Improved Quake C Compiler</p>
23 <li class="buttons"><a href=index.html>Index</a></li>
24 <li class="download"><a href="https://github.com/graphitemaster/gmqcc/archive/0.1.zip">Download v0.1</a></li>
25 <li class="buttons"><a href="https://github.com/graphitemaster/gmqcc/issues">Issues</a></li>
26 <li class="buttons"><a href="doc.html">Documentation</a></li>
27 <li class="buttons"><a href="https://github.com/graphitemaster/gmqcc">View On GitHub</a></li>
32 <li class="wiki"><a class="wiki" href="#cdoc">Compiler Documentation</a></li>
33 <li class="wiki"><a class="wiki" href="#bdoc">Building Documentation</a></li>
34 <li class="wiki"><a class="wiki" href="#tdoc">Testsuite Documentation</a></li>
35 <li class="wiki"><a class="wiki" href="#vdoc">Virtual Machine Documentation</a></li>
37 <h1><a name="cdoc">Compiler Documentation</a></h1>
38 <h3>Defaults Flag</h3>
40 The <i>-show-defaults</i> flag instructs the compiler to print out the defaults used related to
41 the standard, optimization, and code generation. When this flag is specified, the compiler
42 will just print the defaults and quit. No compilation is performed.
44 <pre>$ gmqcc -show-defaults</pre>
45 <h3>Compiling for an alternitive standard</h3>
46 To compile with a different dialect of the QuakeC programming language the <i>-std</i>
47 flag can be instructed to select one of the following options:
51 <td>default standard</td>
55 <td>fteqcc standard</td>
59 <td>vanila QuakeC standard</td>
62 <h2>Common compiler options</h2>
69 <td>-l<path></td>
70 <td>Adds <path> to the directories searched by the preprocessor for include file resolution.</td>
73 <td>-o <file></td>
74 <td>Generates the named executable (progs.src) file (when not specified default is progs.src).</td>
78 <td>-O<level></td>
79 <td>Specfies the optimization level: highest being 3, lowest being 0 (no optimization).</td>
83 <td>Instructs the compiler to only preprocess the input, writing the preprocessed output to stdout</td>
87 <td>Enables all compiled warnings for the selcted standard</td>
91 <td>Instruct the compiler to treat all warnings as errors</td>
94 <td>-std=<standard></td>
95 <td>Selects the standard dialect</td>
98 <h3>Predefined Macros</h3>
102 <td>What it represents</td>
105 <td>__STD_GMQCC__</td>
106 <td>Specifies the current selected standard is gmqcc.</td>
109 <td>__STD_FTEQCC__</td>
110 <td>Specifies the current selected standard is fteqcc.</td>
114 <td>Specifies the current selected standard is qcc.</td>
118 <td>Defined always regardless of the selected standard</td>
121 <td>__STD_VERSION_MINOR__</td>
122 <td>Specifies the current selected stanadards minor version number.</td>
125 <td>__STD_VERSION_MAJOR__</td>
126 <td>Specifies the current selected stanadards major version number.</td>
129 <h3>Unsupported compatability options</h3>
131 GMQCC strives hard for compatability with standard dialects, but not all
132 features of those standards might be implemented. The unsupported features
140 <td>Inline Assembly</td>
144 <td>Macro expansion in strings</td>
149 <h2>Less common compiler options</h2>
150 <h3>Code generation options</h3>
154 <td>What it does</td>
157 <td>-foverlap-locals</td>
158 <td>Reduces codesize by overlapping locals where possible</td>
161 <td>-fdarkplaces-string-table-bug</td>
162 <td>Works around a bug in older Darkplaces engine builds where the stringtable size is computed wrong</td>
165 <td>-fadjust-vector-fields</td>
166 <td>corrects assignment of vector field pointers (STORE_V instead of STORE_FLD)</td>
170 <td>Enables FTEQ preprocessor</td>
173 <td>-frelaxted-switch</td>
174 <td>Relaxes switch statement semantics</td>
177 <td>-fshort-logic</td>
178 <td>Enables short circut evaluation/logic</td>
181 <td>-fperl-logic</td>
182 <td>Enables perl evalutaion/logic</td>
185 <td>-ftranslatable-strings</td>
186 <td>Enables translatable strings via .po file</td>
189 <td>-finitialized-nonconstants</td>
190 <td>Prevents initializations from becoming constant unless 'const' is specified as a qualifer</td>
193 <td>-fassign-function-types</td>
194 <td>Allows function types to be assignable even if their signature is invariant</td>
198 <td>Enables generation of progs.lno for engine VM backtraces</td>
201 <h3>Warning options</h3>
205 <td>What it does</td>
208 <td>-Wunused-uninitialized</td>
209 <td>Enables warnings about unused or uninitialized variables</td>
212 <td>-Wunknwon-control-sequence</td>
213 <td>Enables warnings about unknown control sequences</td>
217 <td>Enables warnings about the use of (an) extension(s)</td>
220 <td>-Wfield-redeclared</td>
221 <td>Enables warnings about redeclared fields</td>
224 <td>-Wmissing-return-values</td>
225 <td>Enables warnings about missing return values</td>
228 <td>-Wtoo-few-paramaters</td>
229 <td>Enables warnings about missing paramaters for function calls</td>
232 <td>-Wlocal-shadows</td>
233 <td>Enables warnings about locals shadowing paramaters or other locals</td>
236 <td>-Wlocal-constants</td>
237 <td>Enables warnings about constants specified as locals</td>
240 <td>-Wvoid-variables</td>
241 <td>Enables warnings about variables declared as type void</td>
244 <td>-Wimplicit-function-pointer</td>
245 <td>Enables warnings about implicitly declared function pointers</td>
248 <td>-Wvariadic-function</td>
249 <td>Enables warnings for use of varadics for non-builtin functions</td>
252 <td>-Wframe-macros</td>
253 <td>Enables warnings about duplicated frame macros</td>
256 <td>-Weffectless-statement</td>
257 <td>Enables warnings about effectiveless statements</td>
260 <td>-Wend-sys-field</td>
261 <td>Enables warnings of end_sys_fields being declared a field</td>
264 <td>-Wassign-function-types</td>
265 <td>Enables warnings for incompatible function pointer signatures used in assignment</td>
268 <td>-Wpreprocessor</td>
269 <td>Enables warnings about redefined macros</td>
272 <td>-Wmultifile-if</td>
273 <td>Enables warnings about multifile if statements</td>
276 <td>-Wdouble-declaration</td>
277 <td>Enables warnings about double declarations</td>
281 <td>Enables warnings about 'const var' and 'var const'</td>
284 <td>-Wmultibyte-character</td>
285 <td>Enables warnings about use of multibyte characters</td>
288 <td>-Wternary-precedence</td>
289 <td>Enables warnings about ternary expressions whos precedence may be not what expected</td>
293 <tr><td>Options</td><td>What it does</td></tr>
295 <td>-Otail-recursion</td>
296 <td>Enables tail recursion optimization</td>
300 Individual warnings may be disabled with -Wno-<warning>
301 <pre>$ gmqcc -Wno-frame-macros # disables frame duplication warning</pre>
303 <h3>Miscellaneous options</h3>
307 <td>What it does</td>
310 <td>-force-crc=<num></td>
311 <td>Forces a specific checsum into the header</td>
315 <td>Turns on compiler debug messages</td>
319 <td>Turns on compiler memory leak checker</td>
322 <td>-Whelp or -W?</td>
323 <td>Lists all warning options</td>
326 <td>-fhelp or -f?</td>
327 <td>Lists all code generation options</td>
330 <td>-redirout=<file></td>
331 <td>Redirect stdout to any file.</td>
334 <td>-redirerr=<file></td>
335 <td>Redirect stderr to any file.</td>
339 <td>Turn off colored stdout/stderr.</td>
343 <h1><a name="bdoc">Building Documentation</a></h1>
344 <h2>Building on BSD/NIX</h2>
346 To compile GMQCC on BSD/NIX the following things are
352 <li>Any C90+ C compiler</li>
355 Once obtained you may checkout the development repository
356 with the following shell commands
358 <pre>$ git clone git://github.com/graphitemaster/gmqcc.git
362 The Makefile contains a few rules, depending on what you
363 want to compile, the following rules are:
368 <td>What it does</td>
372 <td>Builds the gmqcc compiler</td>
376 <td>Builds a standable QuakeC VM</td>
380 <td>Builds the testsuite for GMQCC</td>
384 <td>Builds gmqcc, qcvm, and testsuite</td>
388 <td>Installs gmqcc to /usr/local/</td>
392 <td>Runs the testsuite to verify correctness</td>
396 <h2>Building on Windows</h2>
398 To compile GMQCC on windows the following things are
402 <li><a href="http://msysgit.googlecode.com/files/Git-1.8.0-preview20121022.exe">msysGit</a></li>
403 <li><a href="http://www.microsoft.com/visualstudio/eng/downloads">Visual Studio</a></li>
406 Once obtained you may checkout the development repository
407 with the following msysGit commands from a msysGit shell.
408 <pre>$ git clone git://github.com/graphitemaster/gmqcc.git</pre>
409 Included is a VS project file.
412 <h1><a name="tdoc">Testsuite Documentation</a></h1>
413 <h2>Running The Testsuite</h2>
415 To run the testsuite you can either use
416 <pre>$ make check</pre>
417 Or if you're on windows or have already compiled the
418 testsuite from source:
419 <pre>$ ./testsuite </pre>
421 Optionally you may provide the testsuite with additional
427 <td>What it does</td>
430 <td>-redirout=<file></td>
431 <td>Redirect stdout to any file.</td>
434 <td>-redirerr=<file></td>
435 <td>Redirect stderr to any file.</td>
439 <td>Turn on testsuite debug messages.</td>
443 <td>Turn on testsuite memleak checker.</td>
447 <td>Turn off colored stdout/stderr.</td>
451 <h2>Writing Tests</h2>
453 GMQCC comes with a complete testsuite for verifying semantics
454 and syntatics. The testsuite executes files from the test/
455 directory, by reading task template files.
458 templates are rules for a specific test, used to create a "task" that
459 is executed with those set of rules (arguments, and what not). Tests
460 that don't have a template with them cannot become tasks, since without
461 the information for that test there is no way to properly "test" them.
462 Rules for these templates are described in a template file, using a
463 task template language.
466 The languge is composed entierly of "tags" which describe a string of
467 text for a task. Think of it much like a configuration file. Except
468 it's been designed to allow flexibility and future support for prodecual
472 The following "tags" are suported by the language:
477 <td>Description of what the tag does</td>
481 <td>Used to set a description of the current test, this must be
482 provided, this tag is NOT optional.</td>
486 <td>Used to set a failure message, this message will be displayed
487 if the test fails, this tag is optional.</td>
491 <td>Used to set a success message, this message will be displayed
492 if the test succeeds, this tag is optional.
497 <td>Used to set the procedure for the given task, there are two
501 This simply performs compilation only</li>
503 This will perform compilation and execution</li>
506 This tag must be provided, this tag is NOT optional.
511 <td>Used to set the compilation flags for the given task, this
512 must be provided, this tag is NOT optional.</td>
516 <td>Used to set the execution flags for the given task. This tag
517 must be provided if T == -execute, otherwise it's erroneous
518 as compilation only takes place.</td>
522 <td>Used to describe a string of text that should be matched from
523 the output of executing the task. If this doesn't match the
524 task fails. This tag must be provided at least once if
525 T == -execute, otherwise it's erroneous as compilation only
526 takes place. Multiple M tags are required for multi-line comparision
531 <td>Used to specify the INPUT source file to operate on, this must be
532 provided, this tag is NOT optional</td>
537 These tags (with exception to M) have one-time use, using them more
538 than once will result in template compilation errors,
541 Lines beginning with # or // in the template file are comments and
542 are ignored by the template parser.
543 Whitespace is optional, with exception to the colon ':' between the
544 tag and it's assignment value.
546 The template compiler will detect erronrous tags (optional tags
547 that need not be set), as well as missing tags, and error accordingly
548 which will result in that task failing.
550 <h1><a name="vdoc">Quake C Virtual Machine Documentation</a></h1>
552 Included with GMQCC is a minimal implementation of the QCVM used in many game
553 engines. It's primarly used for the testsuite, but you may also use it as a
554 standalone runtime, or even embed it with existing appliciations.
556 <h2>Running The Standalone VM</h2>
558 To run the standalone application you need to have a compiled progs.dat, with an
559 entry function named main The main function can have any amount of arguments
560 as the standalone executor allows main to be invoked with your choice of arguments.
561 An example of invoking the VM:
562 <pre>$ ./qcvm progs.dat -float 200 #execute passing in 200 as a float to main</pre>
563 If main doesn't require arguments:
564 <pre>$ ./qcvm progs.dat #call main with no arguments</pre>
566 The standalone executor supports the following arguments for passing arguments to main 
571 <td>What it does</td>
575 <td>Passes in a string to main</td>
579 <td>Passes in a float to main</td>
583 <td>Passes in a vector to main</td>
587 The order in which the arguments are expected for main, must be preserved, for
588 example if main 's signature is the following:
589 <pre>void main(float a, vector b)</pre>
591 Then to pass the arguments you'd use the same order:
592 <pre>$ ./qcvm -float 200 -vector '1 2 3'</pre>
594 <h3>Additional Arguments</h3>
595 The standalone virtual machine has the following optional command line arguments:
599 <td>What it does</td>
603 <td>Trace the execution call hierarchy.</td>
607 <td>Profile the bytecode to find hotspots.</td>
611 <td>Get info of the running bytecode.</td>
615 <td>Dissasemble the bytecode into assembly.</td>
619 <td>Prints all definitions for the bytecode running.</td>
622 <td>-printfields</td>
623 <td>Prints all fields for the bytecode running.</td>
628 The standalone virtual machine includes the following builtins.
634 <tr><td>print</td><td>1</td></tr>
635 <tr><td>ftos</td><td>2</td></tr>
636 <tr><td>spawn</td><td>3</td></tr>
637 <tr><td>kill</td><td>4</td></tr>
638 <tr><td>vtos</td><td>5</td></tr>
639 <tr><td>error</td><td>6</td></tr>
640 <tr><td>vlen</td><td>7</td></tr>
641 <tr><td>etos</td><td>8</td></tr>
644 <h3>Support or Contact</h3>
645 <p>Having trouble with GMQCC? Join our IRC channel at #kf-engine on irc.freenode.net or contact <a href="mailto:cube2killfild@gmail.com">Us</a>
648 <script type="text/javascript" src="http://www.ohloh.net/p/602517/widgets/project_partner_badge.js"></script>
651 <!--[if !IE]><script>fixScale(document);</script><![endif]-->